def SimpleReversalSort(pi):
flips = 0
for i in xrange(len(pi)):
j = pi.index(min(pi[i:]))
if (j != i):
flips += 1
pi = pi[:i] + [v for v in reversed(pi[i:j+1])] + pi[j+1:]
print "%2d: rho(%d,%d) = %s" % (flips, i, j, pi)
return pi
test = [ 6,5,3,4,2,1 ]
print test
print SimpleReversalSort(test)