sorts.binary_insertion_sort =========================== .. py:module:: sorts.binary_insertion_sort .. autoapi-nested-parse:: This is a pure Python implementation of the binary insertion sort algorithm For doctests run following command: python -m doctest -v binary_insertion_sort.py or python3 -m doctest -v binary_insertion_sort.py For manual testing run: python binary_insertion_sort.py Attributes ---------- .. autoapisummary:: sorts.binary_insertion_sort.user_input Functions --------- .. autoapisummary:: sorts.binary_insertion_sort.binary_insertion_sort Module Contents --------------- .. py:function:: binary_insertion_sort(collection: list) -> list Sorts a list using the binary insertion sort algorithm. :param collection: A mutable ordered collection with comparable items. :return: The same collection ordered in ascending order. Examples: >>> binary_insertion_sort([0, 4, 1234, 4, 1]) [0, 1, 4, 4, 1234] >>> binary_insertion_sort([]) == sorted([]) True >>> binary_insertion_sort([-1, -2, -3]) == sorted([-1, -2, -3]) True >>> lst = ['d', 'a', 'b', 'e', 'c'] >>> binary_insertion_sort(lst) == sorted(lst) True >>> import random >>> collection = random.sample(range(-50, 50), 100) >>> binary_insertion_sort(collection) == sorted(collection) True >>> import string >>> collection = random.choices(string.ascii_letters + string.digits, k=100) >>> binary_insertion_sort(collection) == sorted(collection) True .. py:data:: user_input