Created
December 11, 2016 14:23
-
-
Save chendi0x7C00/44978db1cfcdd9b78dc8e110cb6460a2 to your computer and use it in GitHub Desktop.
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
| # coding=UTF-8 | |
| import operator | |
| engineers = [{"name": "John", "age": 28}, {"name": "Peter", "age": 20}, {"name": "Paul", "age": 33}] | |
| engineers_sorted_by_age = sorted(engineers, key=operator.itemgetter("age")) | |
| print(engineers_sorted_by_age) | |
| print(engineers) | |
| engineers.sort(key=operator.itemgetter("age"), reverse=True) | |
| print(engineers) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment