#sorted用法:a = [1,5,3,6,2] sorted(a) -> [1,2,3,5,6] sorted(a, reverse=True) -> [6,5,3,2,1] #a = [('b',4), ('a',2), ('c',3), ('d',1)] sorted(a, key=lambda x:x[0] ) -> [('a',4), ('b',2), ('c',3), ('d',1)] #sorted(a, key=lambda x:x[1] ) -> [('d',1), ('a',2), ('c',3), ('b',4)]
sorted排序的用法
猜你喜欢
转载自blog.csdn.net/xiaobaicai4552/article/details/79404608
今日推荐
周排行