Skip to content

Instantly share code, notes, and snippets.

@SpikeXy
Last active October 2, 2017 01:50
Show Gist options
  • Save SpikeXy/e0c3cc857edf7495a37ed380f7cd19b4 to your computer and use it in GitHub Desktop.
Save SpikeXy/e0c3cc857edf7495a37ed380f7cd19b4 to your computer and use it in GitHub Desktop.
Sorted 排序函数 #python
>>> sorted([36, 5, -12, 9, -21])
[-21, -12, 5, 9, 36]
>>> sorted(['bob', 'about', 'Zoo', 'Credit'], key=str.lower)
['about', 'bob', 'Credit', 'Zoo']
>>> sorted(['bob', 'about', 'Zoo', 'Credit'], key=str.lower, reverse=True)
['Zoo', 'Credit', 'bob', 'about']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment