Sort List Of Dictionaries By Key: Python 1 Liner
How can you sort a list of dictionaries by a key contained in each dictionary using Python? Can you do it in 1 line to show off your friends? Of course! To sort a list of dictionaries use the sorted() function with the key parameter set to a lambda function that uses the common key found in each dictionary that you want to sort the list by. Previously I posted a task where I needed to sort a list after the second element onwards, in this article I’ll use the same techniques but apply this to a specific key in each dictionary. ...