sorted() sorts anything you can loop over and returns a new list. Two options do most of the work:
reverse=True sorts from highest to lowest.
key= is a function Python calls on each item; the items are then sorted by what it returns.
sorted(names, key=str.lower) # ignore capitals
sorted(reps, key=lambda r: r["revenue"]) # dictionaries by a field
A lambda is a small function written inline: lambda r: r["revenue"] takes an item and returns its revenue.
To sort by two things, return a tuple: key=lambda t: (t["priority"], t["opened"]) sorts by priority, then by date within each priority. A minus sign in front of a number flips just that part.
Text sorts character by character, so "100" < "95" is True, because "1" comes before "9". Convert numbers stored as text inside the key.