2.1.1 Cocktail sort a slight variation of bubble sort
Another optimization is to alternate the direction of bubbling
each time the inner loop iterates. This is shaker sort or cocktail
shaker sort (see, e.g., [7, 8]). Cocktail sort, also known as
bidirectional bubble sort, cocktail shaker sort, shaker sort
which can also refer to a variant of selection sort), ripple sort,
shuttle sort or happy hour sort, is a variation of bubble sort that
is both a stable sorting algorithm and a comparison sort. The
algorithm differs from bubble sort in that sorts in both
directions each pass through the list. This sorting algorithm is
only marginally more difficult than bubble sort to implement,
and solves the problem with so-called turtles in bubble sort.