Sorting with a key
Sort anything in Python: sorted() with key= and reverse=, lambda functions, sorting by several things at once, dicts by value, and max() and min() with a key.
- The skill
- Sort anything by any rule with key functions, ties included.
- You make
- A price list, an artist chart and a league table with tie-breaks.
Premium lesson
£7.99 a month or £59 a year. Cancel any time.
Builds on 27 Comprehensions. Free to try: Python Foundations and the playground.
Passed
You can now
Keep going
You have what you need for a project: Streaming data analyser Premium 3 hours
Step 1 of 8
exercise_1.py
You've reached the good stuff.
5 exercises in this lesson, checked as you type. Premium opens every lesson after Foundations, in all four courses.
Python 3.13