Table of Contents

About

  • Input: array of n numbers, unsorted.
  • Output: array of n numbers, sorted (from smallest to largest)

Possible Assumption:

  • numbers are distinct
  • with duplicates, the problem can even be easier

Sorting has complexity O(n log n) but repeated sorting can be avoided with a better data structure

Illustration

Manual sorting and counting of 4 million London Underground tickets in 1939 to analyse train use across the network.

Manual Sorting London Ticket

Algorithm