# Written by Eric Martin for COMP9021


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

Resource created Wednesday 21 October 2015, 10:12:28 AM.

file: insertion_sort.py


Back to top

COMP9021 15s2 (Principles of Programming) is powered by WebCMS3
CRICOS Provider No. 00098G