(Edited on 2026-04-14) New version is available here ! (End of edit)

Today, I'd like to talk about a my inspiration.

I (maybe) found new sort algorithm. The source is below.

def sort(iterable):
    iterables_list = [iterable,]
    print(iterables_list)
    while len(iterables_list[-1]) > 1:
        iterables_list.append([])
        print("a", iterables_list)
        i = 0
        while i < len(iterables_list[-2])-1:
            if iterables_list[-2][i] > iterables_list[-2][i+1]:
                iterables_list[-1].append(iterables_list[-2][i+1])
                iterables_list[-2].pop(i+1)
                print("b", iterables_list)
            else:
                i += 1
        print("c", iterables_list)

    if len(iterables_list[-1]) == 0:
        iterables_list.pop()

    while len(iterables_list) > 1:
        i = 0
        while len(iterables_list[-1]) > 0:
            if iterables_list[-1][0] < iterables_list[-2][i]:
                iterables_list[-2].insert(i, iterables_list[-1][0])
                iterables_list[-1].pop(0)
                print("d", iterables_list)
            else:
                i += 1
        iterables_list.pop()
        print("e", iterables_list)
    return iterables_list[0]

This algorithm has two steps, purging and marging.

The first step, purging, this puts elements that aren't in order into the next layer. After the all of layers are sorted, marge them from the last layer.

The best case is all of the elements are in ordered, and the worst case is all of elements are inversed.

Is this exactly new one?