sort() / sorted()
Sorts the list.
Syntax
items.sort() · sorted(arr)
Description
sort() sorts the list IN-PLACE (original changes). sorted() returns NEW sorted items, preserving the original. Sorts in reverse with reverse=True.
Returns
sort() None; sorted() new items.
Example
Loading editor…
Expected output
[1, 2, 3] [5, 4]
When to use?
Scoreboard, alphabetical items, sorting from largest to smallest.