Skip to content

Instantly share code, notes, and snippets.

@chaudharisuresh997
Created January 14, 2021 10:27
Show Gist options
  • Save chaudharisuresh997/34ddfbaa835816751f748a4783423f30 to your computer and use it in GitHub Desktop.
Save chaudharisuresh997/34ddfbaa835816751f748a4783423f30 to your computer and use it in GitHub Desktop.
Python3 cheatsheet
#Sort by the fields comparator
student_tuples = [
('john', 'A', 15),
('jane', 'B', 12),
('dave', 'B', 10),
]
sorted(student_tuples, key=lambda student: student[2]) # sort by age
[('dave', 'B', 10), ('jane', 'B', 12), ('john', 'A', 15)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment