odd even sort implementation https en wikipedia orgwikiodde28093evensort 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 oddevensort5 4 3 2 1 1 2 3 4 5 oddevensort oddevensort10 1 10 2 10 1 2 10 oddevensort1 2 3 4 1 2 3 4 swapping if elements not in order swapping if elements not in order inputing elements of the list in one line 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 until all the indices are traversed keep looping iterating over all even indices swapping if elements not in order iterating over all odd indices swapping if elements not in order inputing elements of the list in one line
def odd_even_sort(input_list: list) -> list:
    
    is_sorted = False
    while is_sorted is False:  
        is_sorted = True
        for i in range(0, len(input_list) - 1, 2):  
            if input_list[i] > input_list[i + 1]:
                input_list[i], input_list[i + 1] = input_list[i + 1], input_list[i]
                
                is_sorted = False

        for i in range(1, len(input_list) - 1, 2):  
            if input_list[i] > input_list[i + 1]:
                input_list[i], input_list[i + 1] = input_list[i + 1], input_list[i]
                
                is_sorted = False
    return input_list


if __name__ == "__main__":
    print("Enter list to be sorted")
    input_list = [int(x) for x in input().split()]
    
    sorted_list = odd_even_sort(input_list)
    print("The sorted list is")
    print(sorted_list)