sorts.heap_sort =============== .. py:module:: sorts.heap_sort .. autoapi-nested-parse:: A pure Python implementation of the heap sort algorithm. Attributes ---------- .. autoapisummary:: sorts.heap_sort.user_input Functions --------- .. autoapisummary:: sorts.heap_sort.heap_sort sorts.heap_sort.heapify Module Contents --------------- .. py:function:: heap_sort(unsorted: list[int]) -> list[int] A pure Python implementation of the heap sort algorithm :param collection: a mutable ordered collection of heterogeneous comparable items :return: the same collection ordered by ascending Examples: >>> heap_sort([0, 5, 3, 2, 2]) [0, 2, 2, 3, 5] >>> heap_sort([]) [] >>> heap_sort([-2, -5, -45]) [-45, -5, -2] >>> heap_sort([3, 7, 9, 28, 123, -5, 8, -30, -200, 0, 4]) [-200, -30, -5, 0, 3, 4, 7, 8, 9, 28, 123] .. py:function:: heapify(unsorted: list[int], index: int, heap_size: int) -> None :param unsorted: unsorted list containing integers numbers :param index: index :param heap_size: size of the heap :return: None >>> unsorted = [1, 4, 3, 5, 2] >>> heapify(unsorted, 0, len(unsorted)) >>> unsorted [4, 5, 3, 1, 2] >>> heapify(unsorted, 0, len(unsorted)) >>> unsorted [5, 4, 3, 1, 2] .. py:data:: user_input