arr = [12, 6, 8, 3, 10, 1, 0, 9] a = zip(range(len(arr)), arr) a.sort(cmp=lambda x,y: cmp(x[1], y[1]), reverse=True) print '\n'.join('%d -> %d' % (x, y) for x, y in a[:3])
#初心者用
a = [12, 6, 8, 3, 10, 1, 0, 9] for i in range(3): b = max(a) z = min(a) c = a.index(b) print str(c) + " -> " + str(b) a[c] = z - 1