bubbleSort(A, N): for i ← 0 to N-2: for j ← N-1 downto i+1 if A[j-1] > A[j]: swap(A[j-1], A[j])