Insertion sort in Python


2013-01-13

def insertion_sort(the_array):
    j = 0
    for i in range(1, len(the_array)):
    j = i
    while ((j > 0) and (the_array[j] < the_array[j-1])):
        the_array[j], the_array[j - 1] = the_array[j - 1], the_array[j]
        j = j - 1