| Programming and Python |
Let Alpha denote the leftmost position.
Let Beta denote the second position from the left.
While Alpha has not yet reached the rightmost position, repeat:
While Beta has not yet passed the right end of the rack, repeat:
if the CD in slot Alpha comes after the one in Beta, then
Swap the CD's in positions Alpha and Beta
Change Beta to denote the slot just right of its old position.
Change Alpha to denote the slot just right of its old position.
Change Beta to denote the slot just right Alpha.
Stop | Programming and Python |