Finalize one position at a time
Selection sort scans the unsorted suffix beginning at position i, remembers the position of its minimum key, and exchanges that element with the element at i. Positions before i then contain the globally smallest i elements in sorted order and are not revisited. Only a candidate position needs to be maintained during the scan. Finding a new candidate does not require an immediate exchange. Keeping selection and movement separate is important: an implementation that swaps on every improvement has a different movement cost from the standard algorithm described here.
A short stability counterexample
Consider [3a,3b,1], where letters identify records with equal keys. Exchanging the minimum 1 with the first record yields [1,3b,3a], reversing the original order of the two 3s. This can happen even if the minimum-selection comparison never replaces a candidate with an equal key. The distant exchange is sufficient to break stability. A stable variant can remove the minimum and shift the intervening range instead, but its movement costs must then be analyzed separately. The standard exchange-based algorithm should not be described as stable.
Sorted input still needs comparisons
On n elements, the suffix scans perform n−1, n−2, and eventually one comparison, totaling n(n−1)/2. An already sorted input does not remove the need to check the rest of each suffix for a smaller element. In contrast, skipping self-exchanges gives at most n−1 actual exchanges. With constant-time comparisons, running time is O(n²) and auxiliary storage is O(1). Counting comparisons and writes separately makes the method easier to evaluate when comparing keys is expensive or when modifying stored records has a particularly high cost.
Choose it for a specific constraint
Selection sort can be a simple choice for tiny arrays or a useful illustration of minimizing exchanges. It is not automatically the best method when writes are expensive: one exchange involves multiple assignments, and an indirect representation may change those costs. It also lacks insertion sort’s ability to exploit a nearly sorted sequence. Check empty arrays, duplicate keys and reversed input, and measure the operations relevant to the application rather than treating every quadratic sorter as equivalent. If preserving equal-key order is required, use an appropriate stable implementation or a different algorithm.