Pseudo-code

The translation of Gnome sort into our pseudo-code notation:

1. Let A be an array of N integers
2. Set P to 1
3. If P = N then stop
4. If A[P] ≥ A[P-1]
   then set P to P+1 and go back to step 3
5. Swap A[P] with A[P-1]
6. If P > 1 then set P to P-1
   else set P to P+1
7. Go back to step 3