Sort Target
Algorithm
Speed
Normal ~12s · 67 ms/step
Quicksort (Bidirectional Stable)(1985)
▶ Try this Source
O(n log n) ✓ Stable ✗ In-place
🔧 How it works

A stable Quicksort that writes less-than elements to the scratch front and greater-than elements to the scratch back in one forward scan, reverses the back section to restore stable order, fills equal elements into the gap, and copies the scratch back. Uses median-of-3 with tail-call elimination.

🎯 Key property

One-pass bidirectional writing replaces the traditional count-then-distribute approach, reducing comparison work when duplicates are rare. The reverse of the greater-than section is the trade-off cost.

👁 Watch for
  • Compare each element is tested once against the pivot to route it to the scratch front or back; a second comparison fires on greater-than candidates to resolve equal elements
  • Swap a short in-place reverse corrects the back section after the scan, restoring left-to-right stability
  • RangeCopy the completed scratch buffer is copied back to the main array after each partition
Initial State
This is the array before sorting. Follow Quicksort (Bidirectional Stable) step by step.
Recursion Tree
[0..9)371952846
0 / 180 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 🗙