procedure bubbleSort( A : list of sortable items ) n = length(A) for i = 0 to n-1 inclusive do for j = 1 to n-i-1 inclusive do //if this pair is out of order if A[j-1] > A[j] then //swap them swap A[j-1] with A[j] end if end for end for end procedure procedure insertionSort( A : list of sortable items ) n = length(A) for i = 1 to n-1 inclusive do current = A[i] j = i - 1 while j>=0 and A[j] > current A[j+1] = A[j] j = j - 1 end while A[j+1] = current end for end procedure procedure selectionSort( A : list of sortable items ) n = length(A) for i = n-1 to 1 inclusive do (note the reverse order) maxPosition = 0 for j = 1 to i inclusive do if A[j] > A[maxPosition] maxPosition = j end if end for swap A[maxPosition] with A[i] end for end procedure