Cocktail shaker sort

ID: cocktail-shaker-sort

Cocktail shaker sort, also known as bidirectional bubble sort or shaker sort, is a variation of the classic bubble sort algorithm. It sorts a list by repeatedly stepping through the list to compare and swap adjacent elements. However, unlike bubble sort, which only passes through the list in one direction, cocktail shaker sort alternates directions. This allows it to move larger elements to the end of the list and smaller elements to the beginning in a single iteration.

New to topics? Read the docs here!