python中的排序

demo:

#coding:utf-8
from functools import cmp_to_key

def cmp1(x,y):
    if x[0]==y[0]:
        return y[1]-x[1]
    else:
        return x[0]-y[0]

A=[[1,2],[3,1],[2,2],[2,1]]
A=sorted(A,key=cmp_to_key(cmp1),reverse=True)
print(A)
原文地址:https://www.cnblogs.com/elpsycongroo/p/9902913.html