sorts.shell_sort ================ .. py:module:: sorts.shell_sort .. autoapi-nested-parse:: https://en.wikipedia.org/wiki/Shellsort#Pseudocode Attributes ---------- .. autoapisummary:: sorts.shell_sort.user_input Classes ------- .. autoapisummary:: sorts.shell_sort.Comparable Functions --------- .. autoapisummary:: sorts.shell_sort.shell_sort 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: Any, /) -> bool .. py:function:: shell_sort[T: Comparable](collection: list[T]) -> list[T] Pure implementation of shell sort algorithm in Python. :param collection: Some mutable ordered collection with heterogeneous comparable items inside :return: the same collection ordered by ascending Examples: >>> shell_sort([0, 5, 3, 2, 2]) [0, 2, 2, 3, 5] >>> shell_sort([]) [] >>> shell_sort([-2, -5, -45]) [-45, -5, -2] >>> shell_sort(["c", "a", "b"]) ['a', 'b', 'c'] >>> shell_sort([2.5, -1.0, 0.0]) [-1.0, 0.0, 2.5] >>> shell_sort([0, 5, 3, 2, 2]) == sorted([0, 5, 3, 2, 2]) True >>> shell_sort(["c", "a", "b"]) == sorted(["c", "a", "b"]) True .. py:data:: user_input