Find the minimum in the remaining suffix and swap it with the first unfixed position. Positions become final from left to right.
A bar-chart simulator of selection sort
Play, step, or seek with the slider. Pink marks the smallest value found so far.
Many comparisons, few swaps
Finding a minimum requires checking every remaining value, even on sorted input. However, each pass performs at most one swap, which can help when moving data is much more expensive than comparing it.
Why is it unstable?
Run Many duplicates to completion and compare the a/b labels on equal values. A long-distance swap can move the displaced value past an equal value, reversing their original order.
Coding exercises
Two useful ideas: stop after k passes to obtain the smallest k values in O(nk), and relate permutation sorting to cycles. For distinct elements, the minimum arbitrary swaps is the number of elements minus the number of permutation cycles.