Menu
Coddy logo textTech

How it works?

Lesson 3 of 9 in Coddy's Radix Sort - DSA Series course.

Radix Sort processes one digit position at a time, from least significant (ones) to most significant. Each pass uses a stable sort so the work done by earlier passes is preserved.

Step-by-Step Process:

  1. Sort by the ones digit using a stable counting sort.
  2. Sort by the tens digit, keeping the previous order for ties.
  3. Continue for the hundreds, thousands, and so on, until you have processed the digit position of the largest number.

Example on [170, 45, 75, 90, 2, 802, 24, 66]:

  • By ones digit: [170, 90, 2, 802, 24, 45, 75, 66]
  • By tens digit: [2, 802, 24, 45, 66, 170, 75, 90]
  • By hundreds digit: [2, 24, 45, 66, 75, 90, 170, 802]

After the last digit, the array is fully sorted. The magic is that stability keeps lower-digit order intact while higher digits take over.

Try it yourself

This lesson doesn't include a code challenge.

quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Radix Sort - DSA Series