sorts.odd_even_sort

Odd even sort implementation.

https://en.wikipedia.org/wiki/Odd%E2%80%93even_sort

Attributes

input_list

Functions

odd_even_sort(→ list)

Sort input with odd even sort.

Module Contents

sorts.odd_even_sort.odd_even_sort(input_list: list) list

Sort input with odd even sort.

This algorithm uses the same idea of bubblesort, but by first dividing in two phase (odd and even). Originally developed for use on parallel processors with local interconnections. :param collection: mutable ordered sequence of elements :return: same collection in ascending order Examples: >>> odd_even_sort([5 , 4 ,3 ,2 ,1]) [1, 2, 3, 4, 5] >>> odd_even_sort([]) [] >>> odd_even_sort([-10 ,-1 ,10 ,2]) [-10, -1, 2, 10] >>> odd_even_sort([1 ,2 ,3 ,4]) [1, 2, 3, 4]

sorts.odd_even_sort.input_list