SELECTION_SORT(A)
- for position ← 0 to A.size()-2 do
- min ← position
- for candidate ← position+1 to A.size()-1 do
- if A[min] > A[candidate] then
- min ← candidate;
- if min ≠ position then
- swap(A[position], A[min])
- return
PERMUTATION_SORT(A)
- while A is not sorted do
- FindNextPermutation(A)
- return