sorts.circle_sort

This is a Python implementation of the circle sort algorithm

For doctests run following command: python3 -m doctest -v circle_sort.py

For manual testing run: python3 circle_sort.py

Attributes

user_input

Functions

circle_sort(→ list)

A pure Python implementation of circle sort algorithm

Module Contents

sorts.circle_sort.circle_sort(collection: list) list

A pure Python implementation of circle sort algorithm

Parameters:

collection – a mutable collection of comparable items in any order

Returns:

the same collection in ascending order

Examples: >>> circle_sort([0, 5, 3, 2, 2]) [0, 2, 2, 3, 5] >>> circle_sort([]) [] >>> circle_sort([-2, 5, 0, -45]) [-45, -2, 0, 5] >>> collections = ([], [0, 5, 3, 2, 2], [-2, 5, 0, -45]) >>> all(sorted(collection) == circle_sort(collection) for collection in collections) True

sorts.circle_sort.user_input