procedure odd_even_sort(array& t) // tells whether array is sorted or not bool is_sorted do is_sorted = true // even index sort for i in range(0,N-1,2) do if t[i] > t[i+1] then swap(t[i], t[i+1]) is_sorted = false // odd index sort for i in range(1, N-2, 2) do if t[i] > t[i+1] then swap(t[i], t[i+1]) is_sorted = false while (not is_sorted) end procedure