Syntax behind sorted(key=lambda: …)

key is a function that will be called to transform the collection’s items before they are compared. The parameter passed to key must be something that is callable. The use of lambda creates an anonymous function (which is callable). In the case of sorted the callable only takes one parameters. Python’s lambda is pretty simple. It can only do and return one thing really. … Read more