Sort numbers one digit at a time from least-significant to most, using a stable pass each time. No comparisons.
Radix sort sorts numbers without ever comparing two of them. It orders them one digit at a time, starting from the rightmost (least-significant) digit and working left. Each pass is a stable bucketing by a single digit. The magic is that stability preserves the work of earlier passes, so after the last digit the whole list is sorted.
It feels backwards to start with the ones digit, but stability is what makes it click. When a later pass sorts by the tens digit, two numbers with the same tens digit keep the order the previous (ones) pass gave them. So higher digits dominate, and within a tie the lower digits — already sorted — break it correctly.
input: 170 45 75 90 802 24 2 66
by 1s digit: 170 90 802 2 24 45 75 66
by 10s digit: 802 2 24 45 66 170 75 90
by 100s digit: 2 24 45 66 75 90 170 802 <- sortedd you need.d passes is an O(n + k) counting sort, where k is the base (10 for decimal digits). Total time is O(d · (n + k)). For fixed-width numbers d is a constant, so radix sort is effectively linear in n.