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