AiTechWorlds
AiTechWorlds
Visualize Radix Sort processing numbers digit by digit with stable counting passes, in linear O(nk) time.
def radix_sort(a):
mx = max(a)
exp = 1
while mx // exp > 0:
out = [0]*len(a); cnt = [0]*10
for x in a: cnt[(x//exp)%10] += 1
for i in range(1, 10): cnt[i] += cnt[i-1]
for x in reversed(a):
d = (x//exp)%10; cnt[d] -= 1; out[cnt[d]] = x
a[:] = out; exp *= 10Radix Sort sorts numbers digit by digit (least-significant first) using a stable counting sort per digit, achieving linear time for fixed-width integer keys.
| Best | O(nk) |
| Average | O(nk) |
| Worst | O(nk) |
| Space | O(n + k) |
| Stable | Yes |
| In-place | No |
The Radix Sort Visualizer animates how Radix Sort works: it sorts numbers digit by digit, from least-significant to most-significant, using a stable counting sort on each digit. Radix Sort runs in O(nk) time for k-digit numbers and is stable, but uses O(n + k) extra space. It is non-comparison based, so it can beat O(n log n) for fixed-width integer keys.
Generate an array
Click New Array or adjust the size slider for a random integer dataset.
Play the animation
Press Play to watch each digit pass redistribute the numbers.
Step and scrub
Step forward/back or drag the timeline to follow each digit placement.
Read the synced code
The highlighted pseudocode line tracks the digit loop; switch tabs for C++, Java, Python, or JavaScript.
100% Private — No Server Required
All processing happens directly in your browser. No data is uploaded, stored, or transmitted to any server.
Last reviewed on June 14, 2026 by the AiTechWorlds Tools Team. All processing runs locally in your browser.