Skip to content

Instantly share code, notes, and snippets.

@sethbunke
Created June 7, 2017 20:26
Show Gist options
  • Save sethbunke/5ac21ee61bd828369ae3e5ce9c5f3485 to your computer and use it in GitHub Desktop.
Save sethbunke/5ac21ee61bd828369ae3e5ce9c5f3485 to your computer and use it in GitHub Desktop.
Python - sort nested tuples
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