COCKTAIL-SORT.JS


comparisons:
swaps:



In cocktail sort, also known as bidirectional bubble sort, an array is traversed, in both directions, comparing adjacent elements, and switching them if they are out of order. Because both the heaviest and lightest elements are sunk and floated rapidly, cocktail sort performs better than bubble sort.

sort.js
bubble-sort.js optimized-bubble-sort.js selection-sort.js
cocktail-sort.js optimized-cocktail-sort.js
odd-even-sort.js comb-sort.js quick-sort.js
gnome-sort.js optimized-gnome-sort.js
compare sort algorithms