Radix Sort
Radix Sort
The Radix Sort algorithm sorts an array by individual digits, starting with the
least significant digit (the rightmost one).
The radix (or base) is the number of unique digits in a number system. In the
decimal system we normally use, there are 10 different digits from 0 till 9.
Radix Sort uses the radix so that decimal values are put into 10 different buckets
(or containers) corresponding to the digit that is in focus, then put back into the
array before moving on to the next digit.
Working Procedure:
Step 2: Sort the values based on the digit in focus by first putting the values in the correct
bucket based on the digit in focus, and then put them back into array in the correct order.
Step 3: Move to the next digit, and sort again, like in the step above, until there are no digits
left.
Radix sort works by sorting the input numbers one digit at a time.
Any stable sorting algorithm ↴ can be used here. In practice, counting sort works well, since
the digits can only take on a small number of values (i.e.: 0 - 9 for base-10 numbers; 0 - 1 for
base-2 numbers).
Here's what sorting on the one's place gets us: