input: Write a python function to sort a list of dictionaries by a given key.
  assert sort_dicts_by_key([{'food': 'apple', 'color': 'red'}, {'food': 'banana', 'color': 'yellow'}, {'food': 'pear', 'color': 'green'}], 'color') == [{'food': 'apple', 'color': 'red'}, {'food': 'pear', 'color': 'green'}, {'food': 'banana', 'color': 'yellow'}]
  assert sort_dicts_by_key([{'name': 'John', 'age': 25}, {'name': 'Jane', 'age': 22}, {'name': 'Doe', 'age': 23}], 'age') == [{'name': 'Jane', 'age': 22}, {'name': 'Doe', 'age': 23}, {'name': 'John', 'age': 25}]
  assert sort_dicts_by_key([{'city': 'New York', 'population': 8419000}, {'city': 'Los Angeles', 'population': 3980000}, {'city': 'Chicago', 'population': 2716000}], 'population') == [{'city': 'Chicago', 'population': 2716000}, {'city': 'Los Angeles', 'population': 3980000}, {'city': 'New York', 'population': 8419000}]
output: def sort_dicts_by_key(lst, key):
      return sorted(lst, key=lambda x: x[key])