selectionSort(A, n)
begin
for i ← 0 to n-2 do
minIdx ← i
for j ← i+1 to n-1 do
if A[j] < A[minIdx] then
minIdx ← j
swap A[i] ↔ A[minIdx]
end