One index walks the array: forward when the pair is in order, back after a swap.
This interactive visualization needs JavaScript.