Bubble Sort (Advanced)

def bubblesort(lst):
    done = False
    while not done:
        done = True
        for x in range(len(lst) - 1):
            if lst[x] > lst[x + 1]:
                swap(lst, x, x + 1)
                done = False
Advertisements