sorts.odd_even_transposition_single_threaded

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

This is a non-parallelized implementation of odd-even transposition sort.

Normally the swaps in each set happen simultaneously, without that the algorithm is no better than bubble sort.

Attributes

arr

Functions

odd_even_transposition(→ list)

Module Contents

sorts.odd_even_transposition_single_threaded.odd_even_transposition(arr: list) list
>>> odd_even_transposition([5, 4, 3, 2, 1])
[1, 2, 3, 4, 5]
>>> odd_even_transposition([13, 11, 18, 0, -1])
[-1, 0, 11, 13, 18]
>>> odd_even_transposition([-.1, 1.1, .1, -2.9])
[-2.9, -0.1, 0.1, 1.1]
sorts.odd_even_transposition_single_threaded.arr