Skip to content

Commit a4d628b

Browse files
authored
Update itemgetter_sorting_dictionaries.py
1 parent 0b14d39 commit a4d628b

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

working-with-the-python-operator-module/itemgetter_sorting_dictionaries.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import operator
2+
13
musicians = [
24
{"id": 1, "fname": "Brian", "lname": "Wilson", "group": "Beach Boys"},
35
{"id": 2, "fname": "Carl", "lname": "Wilson", "group": "Beach Boys"},
@@ -8,7 +10,5 @@
810
{"id": 7, "fname": "Brian", "lname": "Bennett", "group": "Shadows"},
911
]
1012

11-
import operator
12-
1313
get_names = operator.itemgetter("lname", "fname")
1414
print(sorted(musicians, key=get_names, reverse=True))

0 commit comments

Comments
 (0)