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)