sorts.cocktail_shaker_sort ========================== .. py:module:: sorts.cocktail_shaker_sort .. autoapi-nested-parse:: An implementation of the cocktail shaker sort algorithm in pure Python. https://en.wikipedia.org/wiki/Cocktail_shaker_sort Attributes ---------- .. autoapisummary:: sorts.cocktail_shaker_sort.user_input Functions --------- .. autoapisummary:: sorts.cocktail_shaker_sort.cocktail_shaker_sort Module Contents --------------- .. py:function:: cocktail_shaker_sort(arr: list[int]) -> list[int] Sorts a list using the Cocktail Shaker Sort algorithm. :param arr: List of elements to be sorted. :return: Sorted list. >>> cocktail_shaker_sort([4, 5, 2, 1, 2]) [1, 2, 2, 4, 5] >>> cocktail_shaker_sort([-4, 5, 0, 1, 2, 11]) [-4, 0, 1, 2, 5, 11] >>> cocktail_shaker_sort([0.1, -2.4, 4.4, 2.2]) [-2.4, 0.1, 2.2, 4.4] >>> cocktail_shaker_sort([1, 2, 3, 4, 5]) [1, 2, 3, 4, 5] >>> cocktail_shaker_sort([-4, -5, -24, -7, -11]) [-24, -11, -7, -5, -4] >>> cocktail_shaker_sort(["elderberry", "banana", "date", "apple", "cherry"]) ['apple', 'banana', 'cherry', 'date', 'elderberry'] >>> cocktail_shaker_sort((-4, -5, -24, -7, -11)) Traceback (most recent call last): ... TypeError: 'tuple' object does not support item assignment .. py:data:: user_input