Sort Target
Algorithm
Speed
Normal ~12s · 138 ms/step
Comb sort(1980)
▶ Try this Source
O(n²) ✗ Stable ✓ In-place
🔧 How it works

Compares elements separated by a large gap and swaps them if out of order, then shrinks the gap by a factor of ~1.3 each pass until it reaches 1, at which point the remaining passes behave identically to Bubble sort.

🎯 Key property

The large initial gap moves "turtles", small values stranded near the end of the array, to their correct region far more quickly than Bubble sort's adjacent-only swaps, dramatically reducing total work.

👁 Watch for
  • Compare highlighted pairs are separated by the current gap rather than being adjacent; the gap distance is clearly visible in the animation
  • Swap fires when element at position i > element at position i+gap, moving the larger value rightward by a full gap width in one step
  • End of pass watch the gap value shrink each pass until it reaches 1, after which the algorithm completes with standard Bubble sort passes
Initial State
This is the array before sorting. Follow Comb sort step by step.
Main Array
5
0
3
1
8
2
1
3
9
4
2
5
7
6
4
7
0 / 87 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 🗙