sorts.bubble_sort_recursive =========================== .. py:module:: sorts.bubble_sort_recursive .. autoapi-nested-parse:: A pure Python implementation of the recursive bubble sort algorithm. Classes ------- .. autoapisummary:: sorts.bubble_sort_recursive.Comparable Functions --------- .. autoapisummary:: sorts.bubble_sort_recursive.bubble_sort_recursive Module Contents --------------- .. py:class:: Comparable Bases: :py:obj:`Protocol` Base class for protocol classes. Protocol classes are defined as:: class Proto(Protocol): def meth(self) -> int: ... Such classes are primarily used with static type checkers that recognize structural subtyping (static duck-typing). For example:: class C: def meth(self) -> int: return 0 def func(x: Proto) -> int: return x.meth() func(C()) # Passes static type check See PEP 544 for details. Protocol classes decorated with @typing.runtime_checkable act as simple-minded runtime protocols that check only the presence of given attributes, ignoring their type signatures. Protocol classes can be generic, they are defined as:: class GenProto[T](Protocol): def meth(self) -> T: ... .. py:method:: __lt__(other: object, /) -> bool .. py:function:: bubble_sort_recursive[T: Comparable](arr: list[T]) -> list[T] Sorts a list of comparable items using the recursive Bubble Sort algorithm. >>> bubble_sort_recursive([5, 1, 4, 2, 8]) [1, 2, 4, 5, 8] >>> bubble_sort_recursive([]) [] >>> bubble_sort_recursive([1]) [1] >>> bubble_sort_recursive([3, 3, 2, 1]) [1, 2, 3, 3] >>> bubble_sort_recursive([-1, 5, 0, -2]) [-2, -1, 0, 5] >>> bubble_sort_recursive(["banana", "apple", "cherry"]) ['apple', 'banana', 'cherry'] >>> bubble_sort_recursive([3.14, 1.5, 2.7]) [1.5, 2.7, 3.14] >>> bubble_sort_recursive([1, "two"]) # doctest: +ELLIPSIS Traceback (most recent call last): ... TypeError: ...