Selection sort keeps a sorted prefix on the left and an unsorted remainder on the right. At each step it finds the minimum of the remainder and swaps it with the first element of the remainder. It makes many comparisons but at most n - 1 swaps. The properties are described in sorting properties.

Selection sort on 64 25 12 22 11
Selection sort on 64 25 12 22 11

The invariant

After i steps a[:i] contains the i smallest elements of the array in sorted order, and every element of the remainder is not smaller than any element of the prefix. When i = n - 1 the last element is automatically in place.

python
a = [64, 25, 12, 22, 11]
n = len(a)
for i in range(n - 1):
    m = i
    for j in range(i + 1, n):
        if a[j] < a[m]:
            m = j
    a[i], a[m] = a[m], a[i]
    print("i =", i, "min at", m, a)