xiaolizi007
4/25/2017 - 7:09 AM

Sorted 排序函数

Sorted 排序函数 #python

>>> sorted(['bob', 'about', 'Zoo', 'Credit'], key=str.lower, reverse=True)
['Zoo', 'Credit', 'bob', 'about']
>>> sorted(['bob', 'about', 'Zoo', 'Credit'], key=str.lower)
['about', 'bob', 'Credit', 'Zoo']
>>> sorted([36, 5, -12, 9, -21])
[-21, -12, 5, 9, 36]