#simple bubble sort using definite iteration #this always checks everything, even when the #list is already sorted #passes will always be the length of the list - 1 theList = [9, 4, 6, 2, 7, 8, 1, 5, 3] passes = 0 for j in range(0, len(theList)-1): passes = passes + 1 for i in range(0, len(theList)-1): if theList[i] > theList[i+1]: theList[i], theList[i+1] = theList[i+1], theList[i] print("sorted") print(theList) print(passes)