Snippets tagged “key-function”
1 snippet uses this tag.
- How to sort a list of objects based on an attribute of the objects?Python
You can use the sort method of a list and pass in a key argument, which is a function that takes an object and returns the value on which you want to sort the list.