sort()
noun
say it: “sort” /sɔːrt/
A list method that puts the list itself in order, smallest first, or largest first with reverse=True; it changes the list and gives back None.
What does sort() do?
sort() puts a list in order, changing the list itself. Add reverse=True for biggest first.
scores = [72, 95, 88]
scores.sort(reverse=True)
print(scores) # [95, 88, 72]
In a sentence
- “sort() with reverse=True put the highest score first.”
- “scores.sort() changed the list in place, so the old order was gone.”
Level: Apprentice · More Python terms at this level
Updated