8.4. Sorting

Another common operation computers need to use on lists of data is to sort them. What are the top 10 results on a web search the the term “sort algorithm”?, Rank the states of the US based on population, Print an alphabetical class roster - these are all examples of tasks that require putting data in some kind of order. Sometimes we need to sort data to enable the use of some other algorithm, like binary search, even if we don’t actually care what order the date is in.

Before you start reading about standard sorting algorithms, try the quick activity below - see if you can come up with your own sorting algorithm.