Sort Target
Algorithm
Speed
Normal ~12s · 214 ms/step
LSD Radix sort (b=4)(1954)
▶ Try this Source
O(nk) ✓ Stable ✗ In-place
🔧 How it works

Sorts integers digit by digit from the least significant to the most significant 2-bit group, applying a stable counting sort at each pass so that the order established by previous passes is never disturbed.

🎯 Key property

Base 4 (2-bit groups) keeps the per-pass counting table to just four slots, minimising the memory footprint per pass at the cost of requiring more passes than larger bases.

👁 Watch for
  • IndexRead each element's current 2-bit digit group is extracted by a bitwise operation; the digit value increments its slot in the four-entry counting table
  • IndexWrite the prefix-sum pass converts counts to output positions; elements are then written to the output buffer in stable order by their current digit
  • End of pass each pass produces an array sorted by all digit positions processed so far; watch the partial order grow pass by pass from the least significant bits upward
Initial State
This is the array before sorting. Follow LSD Radix sort (b=4) step by step.
Main Array
5
0
3
1
8
2
1
3
9
4
2
5
7
6
4
7
BucketsScatter— bits 0-1Pass 1
0
1
2
3
0 / 56 ops ( 0.0%) 0.0%
Sorting is
a spectacle.
Algorithms at work, in a daily vertical feed. Watch, play, challenge — and go deeper when you're ready.
Loading 0%
An unhandled error has occurred. Reload 🗙