insertionSort(A, n)
begin
for i ← 1 to n-1 do
key ← A[i]
j ← i - 1
while j ≥ 0 and A[j] > key do
A[j+1] ← A[j]
j ← j - 1
A[j+1] ← key
end