Implement the cocktail shaker sort (bidirectional bubble sort) for an array of integers. Optimize it with early termination and shrinking bounds, and include basic tests. Analyze time and space complexity, stability, and when it outperforms or underperforms standard bubble sort; provide worst-, average-, and best-case comparisons and swaps.