Selects the smallest remaining element and places it into the next position.
for i from 0 to n-1 min = i; for j from i+1 to n-1 if a[j] < a[min] min = j swap a[i], a[min] mark i as sorteddone