I have been racking my head trying to wrap my mind around this thing, but I cannot figure out the proper loop invariant and expected behavior of the following code. Any help would be much appreciated.
def modSwapSort(L):
""" L is a list on integers """
print "Original L: ", L
for i in range(len(L)):
for j in range(len(L)):
if L[j] < L[i]:
# the next line is a short
# form for swap L[i] and L[j]
L[j], L[i] = L[i], L[j]
print L
print "Final L: ", L