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

Scans the entire unsorted region to find the minimum element, then swaps it with the first unsorted element, repeating until the array is sorted.

🎯 Key property

At most one swap per pass, the theoretical minimum among O(n²) sorts, making it the best choice when memory writes are far more expensive than reads.

👁 Watch for
  • Compare the scan pointer advances right through the unsorted region, silently updating the minimum candidate index without moving any elements
  • Swap exactly one long-distance swap per pass, jumping the found minimum directly from its current position to the front of the unsorted region
  • End of pass the left sorted boundary advances by exactly one element; total passes needed is n − 1
Initial State
This is the array before sorting. Follow Selection sort step by step.
Main Array
5
0
3
1
8
2
1
3
9
4
2
5
7
6
4
7
0 / 90 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 🗙