Insert Sort 2

def insertsort2(lst):
    for x in range(len(lst)): #for each element
        el = lst[x] #pick up the element
        while x > 0 and el < lst[x - 1]:
            lst[x] = lst[x - 1]
            x -= 1
        lst[x] = el #drop the element
Advertisements