Radix sort

How can you sort numbered cards by looking at just one digit at a time? Put 31 and 21 in box 1 and 12 in box 2.

Start with the ones. Gather boxes 0 through 9, then repeat for tens, hundreds and so on.

Take cards from each box in arrival order. After the tens pass, cards with equal tens still appear in ones order.

For n cards and d digits, time is O(d · (n + 10)) and extra space is O(n + 10).