Created
June 7, 2017 20:26
-
-
Save sethbunke/5ac21ee61bd828369ae3e5ce9c5f3485 to your computer and use it in GitHub Desktop.
Python - sort nested tuples
This file contains hidden or 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
data = [(1, ('a','a')), (2, ('z','z')), (3, ('c','c')), (4,('d','d'))] | |
result = sorted(data, reverse=True) | |
print(result) | |
#[(4, ('d', 'd')), (3, ('c', 'c')), (2, ('z', 'z')), (1, ('a', 'a'))] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment