Radix Sort Buckets Screensaver
The Radix Sort Buckets screensaver runs a real LSD radix sort, dropping numbers into ten digit buckets pass by pass until the array is fully sorted. It is free, runs in your browser, and ESC exits.
How the Radix Sort Buckets screensaver works
The saver shuffles a real array of numbers, then sorts it with a real least-significant-digit radix sort.
Each pass, every number drops into one of ten real buckets based on its current digit, from ones up through the highest digit present.
After each pass the buckets empty back into the array in bucket order, exactly as real radix sort requires, and the next digit pass begins.
Once every digit position has been processed, the array is fully sorted; it holds briefly, then a fresh shuffle begins.
Sorting without comparing
Most well-known sorting methods work by comparing pairs of items, and a result from information theory says that any such method needs on the order of n log n comparisons in the worst case. Radix sort sidesteps that limit by never comparing two numbers directly. Instead it uses the digits themselves as addresses, dropping each value into a bucket labelled by its digit.
The version that starts from the least significant digit, called LSD radix sort, makes one pass for each digit position. What makes it correct is stability: within each pass, numbers keep their relative order whenever they share a digit. Because earlier passes sorted by lower digits, a later pass on a higher digit leaves ties properly ordered, and after the final pass the whole list is sorted.
The idea is old. Radix sorting traces back to 1887 and Herman Hollerith's tabulating machines, and punched-card sorting by this method was common by 1923. Harold Seward at MIT devised the first memory-efficient computer version in 1954. Run time is O(d times n) for n keys of d digits, which beats comparison sorts when keys are short, but it needs extra memory for the buckets and depends on the key format.
A worked example
After the ones-digit pass, numbers ending in the same digit cluster together in the same bucket regardless of their other digits, exactly the real intermediate state radix sort produces.
Settings & tips
- Accent recolours the active digit bucket.
- This is a real, correct LSD radix sort implementation.
- A fresh shuffle starts automatically once every digit pass completes.
Frequently asked questions
- Is this a real radix sort?
- Yes — a real, correct least-significant-digit radix sort, with every bucket pass shown as it happens.
- Why ten buckets?
- Real base-10 radix sort uses one bucket per possible digit value, zero through nine.
- Is a key needed?
- No — it is a pure local computation.
- Is it free?
- Yes — free, no download, in your browser.
- Why must each pass be stable?
- Stability keeps the order established by earlier, lower-digit passes whenever two numbers share the current digit, which is what makes the final result fully sorted.
- Can radix sort beat n log n?
- For fixed-size keys, yes, because it is not a comparison sort and so the comparison lower bound does not apply.
- Does it work on negative numbers or text?
- Yes with adjustments. For two's complement integers the sign bit has to be treated with the opposite sense, and strings can be sorted by character positions using the same bucket idea.