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

Performs Quicksort's partition step using an auxiliary buffer to collect elements from each side in their original order, then writes them back, preserving the relative order of equal elements.

🎯 Key property

Stability requires O(n) auxiliary space per partition, the direct cost of guaranteeing that equal elements keep their original ordering, which standard in-place Quicksort cannot provide.

👁 Watch for
  • Compare each element is compared against the pivot twice per partition — once in a counting pass to size each side, then again while distributing to the buffer — for ~2n log₂ n comparisons on average
  • RangeCopy elements from each partition are copied into an auxiliary buffer in their original order to preserve stability
  • IndexWrite elements are written back from the buffer to the main array; equal elements appear in the same relative order as before the partition
Initial State
This is the array before sorting. Follow Quicksort (Stable) step by step.
Recursion Tree
[0..9)371952846
0 / 179 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 🗙