The max(), min(), and sorted() functions have a default behavior without a key= function. They can be customized by providing a function that defines how to compute a key from the available data. For many of our examples, the key() function has been a simple extraction of available data. This isn't a requirement; the key() function can do anything.
Imagine the following method: max(trip, key=random.randint()). Generally, we try not to have have key() functions that do something obscure like this.
The use of a key= function is a common design pattern. Functions we design can easily follow this pattern.
We've also looked at lambda forms that we can use to simplify using higher-order functions. One significant ...