this is pure python implementation of comb sort algorithm comb sort is a relatively simple sorting algorithm originally designed by wlodzimierz dobosiewicz in 1980 it was rediscovered by stephen lacey and richard box in 1991 comb sort improves on bubble sort algorithm in bubble sort distance or gap between two compared elements is always one comb sort improvement is that gap can be much more than 1 in order to prevent slowing down by small values at the end of a list more info on https en wikipedia orgwikicombsort for doctests run following command python m doctest v combsort py or python3 m doctest v combsort py for manual testing run python combsort py pure implementation of comb sort algorithm in python param data mutable collection with comparable items return the same collection in ascending order examples combsort0 5 3 2 2 0 2 2 3 5 combsort combsort99 45 7 8 2 0 15 3 15 7 0 2 3 8 45 99 update the gap value for a next comb swap values pure implementation of comb sort algorithm in python param data mutable collection with comparable items return the same collection in ascending order examples comb_sort 0 5 3 2 2 0 2 2 3 5 comb_sort comb_sort 99 45 7 8 2 0 15 3 15 7 0 2 3 8 45 99 update the gap value for a next comb swap values
def comb_sort(data: list) -> list:
    
    shrink_factor = 1.3
    gap = len(data)
    completed = False

    while not completed:
        
        gap = int(gap / shrink_factor)
        if gap <= 1:
            completed = True

        index = 0
        while index + gap < len(data):
            if data[index] > data[index + gap]:
                
                data[index], data[index + gap] = data[index + gap], data[index]
                completed = False
            index += 1

    return data


if __name__ == "__main__":
    import doctest

    doctest.testmod()

    user_input = input("Enter numbers separated by a comma:\n").strip()
    unsorted = [int(item) for item in user_input.split(",")]
    print(comb_sort(unsorted))