Sortingcore
Cocktail Shaker
A bidirectional bubble sort: each round bubbles the largest element to the right, then the smallest to the left. Shaking both ways clears "turtles" (small values near the end) faster than plain bubble sort.
- Best
- O(n)
- Average
- O(n²)
- Worst
- O(n²)
- Space
- O(1)
- Stable
- Yes