04 Try it yourself Interactive

Watch the gap open and the bigger values slide into it

Press Next to advance one operation. The bars, the highlighted code line and the sentence underneath always describe the same moment. A short grey stub is the gap where the key used to sit, amber marks a comparison, rose marks a value that is moving, and green is the sorted prefix built so far. Switch to the swapping tab to run the naive version on the same list and watch the write counter climb faster for identical work.

Shifting version
one write per slide
2–9 whole numbers (0–99), commas or spaces.
Press Next to begin. Each press moves one step.


      
Value in motion
At slot
Comparisons0
Array writes0
step 0 / 0