码迷,mamicode.com
首页 > 编程语言 > 详细

python中的排序

时间:2018-11-04 11:18:00      阅读:142      评论:0      收藏:0      [点我收藏+]

标签:demo   port   coding   turn   utf-8   too   UNC   code   ret   

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)

 

python中的排序

标签:demo   port   coding   turn   utf-8   too   UNC   code   ret   

原文地址:https://www.cnblogs.com/elpsycongroo/p/9902913.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!