Python: Dictionary: Sort By Key

Write the function sort_by_key that takes a list of dictionary lst and a string key and returns another list whose elements are sorted by key.

lst = [{'name': 'Dave', 'age': 20}, {'name': 'Sarah', 'age': 15}, {'name': 'Noah', 'age': 31}]
sort_by_key(lst, 'age') -> [{'name': 'Sarah', 'age': 15}, {'name': 'Dave', 'age': 20}, {'name': 'Noah', 'age': 31}]

Test 1    

Test 2    

Test 3    

Test 4    

Test 5    

Test 6