AlgoScope

Stable Sorting

Equal keys keep their original relative order.

Complexity analysis, analysis, beginner
Pass 0 selects 1 at index 3. It swaps into index 0. The tagged values are now out of order.10315253ij
Pass 0 selects 1 at index 3. It swaps into index 0. The tagged values are now out of order.10315253ij

Stable Sorting: Selection sort flips it

Decision, step 2 of 5

Pass 0: the smallest of the rest is 1 at index 3. Swap it into index 0. The 5 that sat there jumps to index 3, past everything in between. That carried a tagged 5 past its twin: the order flipped.

How stable sorting works

Cost

Space
O(1)