DSA · Reimagined
Sorting hard time O(d · (n + b)) space O(n + b)

Radix Sort

Sort the numbers by their last digit, then the next digit, and so on. Each pass is a stable counting sort on one digit (base 10). After the most-significant digit, the whole array is sorted.

array
170
0
45
1
75
2
90
3
24
4
2
5
66
6
digit counts (0–9)
0
0
0
1
0
2
0
3
0
4
0
5
0
6
0
7
0
8
0
9
output
0
1
2
3
4
5
6

Radix sort: stably sort by each digit, least-significant first.

1 / 53

Practice

Machine twin: /dsa-viz-v2/radix-sort.json — the full deterministic run as structured data.