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

Recursively splits the array in half until each sub-array holds a single element, then merges adjacent sub-arrays back together in sorted order, building the fully sorted array bottom-up through the call stack.

🎯 Key property

Stable and guarantees O(n log n) in all cases, but requires an auxiliary array of the same size as the input to perform each merge step, the classic space-vs-stability trade-off.

👁 Watch for
  • RangeCopy both halves of the current sub-array are copied into a temporary buffer before the merge begins
  • Compare the merge reads from both buffer halves simultaneously, always picking the smaller front value to write back
  • IndexWrite the chosen value is written back to the original array one position at a time until both buffer halves are exhausted
Initial State
This is the array before sorting. Follow Merge sort step by step.
Recursion Tree
[0..8)53819274
0 / 81 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 🗙