sorts.recursive_insertion_sort ============================== .. py:module:: sorts.recursive_insertion_sort .. autoapi-nested-parse:: A recursive implementation of the insertion sort algorithm Attributes ---------- .. autoapisummary:: sorts.recursive_insertion_sort.numbers Functions --------- .. autoapisummary:: sorts.recursive_insertion_sort.insert_next sorts.recursive_insertion_sort.rec_insertion_sort Module Contents --------------- .. py:function:: insert_next(collection: list, index: int) Inserts the '(index-1)th' element into place >>> col = [3, 2, 4, 2] >>> insert_next(col, 1) >>> col [2, 3, 4, 2] >>> col = [3, 2, 3] >>> insert_next(col, 2) >>> col [3, 2, 3] >>> col = [] >>> insert_next(col, 1) >>> col [] .. py:function:: rec_insertion_sort(collection: list, n: int) Given a collection of numbers and its length, sorts the collections in ascending order :param collection: A mutable collection of comparable elements :param n: The length of collections >>> col = [1, 2, 1] >>> rec_insertion_sort(col, len(col)) >>> col [1, 1, 2] >>> col = [2, 1, 0, -1, -2] >>> rec_insertion_sort(col, len(col)) >>> col [-2, -1, 0, 1, 2] >>> col = [1] >>> rec_insertion_sort(col, len(col)) >>> col [1] .. py:data:: numbers