Home » Python » How do I sort a list of dictionaries by a value of the dictionary in Python?

How do I sort a list of dictionaries by a value of the dictionary in Python?

Posted by: admin October 4, 2018 Leave a comment

Questions:

I got a list of dictionaries and want that to be sorted by a value of that dictionary.

This

[{'name':'Homer', 'age':39}, {'name':'Bart', 'age':10}]

sorted by name, should become

[{'name':'Bart', 'age':10}, {'name':'Homer', 'age':39}]
Answers: