Last active
October 2, 2017 01:50
-
-
Save SpikeXy/e0c3cc857edf7495a37ed380f7cd19b4 to your computer and use it in GitHub Desktop.
Sorted 排序函数 #python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> sorted([36, 5, -12, 9, -21]) | |
[-21, -12, 5, 9, 36] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> sorted(['bob', 'about', 'Zoo', 'Credit'], key=str.lower) | |
['about', 'bob', 'Credit', 'Zoo'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> 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