sorts.cyclic_sort ================= .. py:module:: sorts.cyclic_sort .. autoapi-nested-parse:: This is a pure Python implementation of the Cyclic Sort algorithm. For doctests run following command: python -m doctest -v cyclic_sort.py or python3 -m doctest -v cyclic_sort.py For manual testing run: python cyclic_sort.py or python3 cyclic_sort.py Attributes ---------- .. autoapisummary:: sorts.cyclic_sort.user_input Functions --------- .. autoapisummary:: sorts.cyclic_sort.cyclic_sort Module Contents --------------- .. py:function:: cyclic_sort(nums: list[int]) -> list[int] Sorts the input list of n integers from 1 to n in-place using the Cyclic Sort algorithm. :param nums: List of n integers from 1 to n to be sorted. :return: The same list sorted in ascending order. Time complexity: O(n), where n is the number of integers in the list. Examples: >>> cyclic_sort([]) [] >>> cyclic_sort([3, 5, 2, 1, 4]) [1, 2, 3, 4, 5] .. py:data:: user_input