[[問題文>練習問題#u170a96a]] 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 = zip(xrange(len(arr)), arr) a.sort(key=lambda e: e[1], reverse=1) print '\n'.join('{0} -> {1}'.format(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