'''
Created on Dec 1, 2014

@author: Susan
'''
def swap(i,j, somelist):
    # swap the elements in positions i and j of somelist
    # TODO:
    temp = somelist[i]
    somelist[i] = somelist[j]
    somelist[j] = temp
 
def BubbleSort(items):
    for iIndex in range(len(items)):
        for jIndex in range(0,len(items)-1-iIndex):
            # TODO:
            if items[jIndex] > items[jIndex+1]:
                swap(jIndex, jIndex+1, items)
        print "One pass is: ", items
        
    
    
    
alist = [3, 7, 2, 9, 1, 8, 6]
print "list before sorting is: ", alist
BubbleSort(alist)
print "list after sorting is: ", alist

