'''
Created on Dec 1, 2014

@author: Susan
'''
def swap(i,j, somelist):
    # TODO:
    temp = somelist[i]
    somelist[i] = somelist[j]
    somelist[j] = temp
 
def InsertionSort(items):
    for iIndex in range(1,len(items)):
        # put item at iIndex where it belongs
        jIndex = iIndex
        while jIndex > 0 and items[jIndex] < items[jIndex - 1]:
            swap(jIndex, jIndex-1, items)
            jIndex -= 1
        print items
    
        
    
    
    
alist = [3, 7, 2, 9, 1, 8, 6]
InsertionSort(alist)
print alist
