Lists – Sorting with sorted() and .sort()
sorted(x) returns a new sorted list and leaves x unchanged. x.sort() sorts the list x itself (in place) and returns None. Both accept reverse=True and key= to change the order.
Understanding Lists – Sorting with sorted() and .sort() in VCE Software Development U3O1
What it does: Adding reverse=True flips the normal ascending order so the biggest value comes first. The key= function picks which value from each dictionary is used to decide the order, here the age. sorted() returns a new sorted list and leaves the original list unchanged. .sort() sorts the list in place, so the original list itself is changed. key= needs the function itself (len), not a call to it. Python calls the function on each item for you. Assigning the result of .sort() throws away the list because the method returns None. The new sorted list from sorted() must be stored in a variable, otherwise it is lost.
Common mistakes: Lists have no .sorted() method. sorted() is a built-in function that takes the list as an argument, so the line should be ranked = sorted(scores). Round brackets make a tuple, and tuples have no .sort() method, so line 2 would crash. The list needs square brackets: names = ['Zed', 'Amy', 'Bo'].
Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.
This module's key terms are also in a printable crossword (Modules 142–155) and word search (Modules 142–166).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
sorted() and .sort()Fill in the Blanks
Spot the Error
Student with a class code? Join your class →