Beating the n log n wall: counting and radix sort

A pile of numbers split around a pivot and put back in order. This lesson sorts the same kind of pile without ever comparing two numbers.
A state board has published the exam results for 1,000,000 students. Every mark is a whole number from 0 to 100. The board needs a rank list, highest mark first, and it needs it in seconds. The usual sort works, but it does more work than needed. Marks are small numbers you can count.
By the end you will be able to sort numbers in a single pass or a few passes with no comparisons, say when that beats the library sort, and say when it loses.
The history (optional)
Herman Hollerith’s tabulating system for the 1890 US census had a sorting box: an oak box with 26 compartments, and a lid opened for the compartment where a card belonged (Smithsonian, National Museum of American History). Radix sorting dates back to his work in 1887. By 1923 it was in common use for sorting punched cards (Wikipedia, “Radix sort”). In 1954 Harold H. Seward, in a master’s thesis at MIT, gave counting sort and the first memory-efficient computer version of radix sort. His idea was one scan to learn how big each bucket must be, so the memory could be set aside once.
Before you start. Sorting & Searching gave you quicksort, merge sort and the argument that no sort which only compares items can beat about n log n comparisons. Complexity & Big-O gave you the idea that work grows with input size, and that log n grows very slowly. Hashing gave you the idea of using a value as a position in an array. This lesson uses that last idea to avoid comparing.