input: Write a python function to sort a list of dictionaries based on a given key.
  assert sort_list([{'name': 'apple', 'price': 10}, {'name': 'banana', 'price': 5}], 'price') == [{'name': 'banana', 'price': 5}, {'name': 'apple', 'price': 10}]
  assert sort_list([{'name': 'apple', 'price': 10}, {'name': 'banana', 'price': 5}], 'name') == [{'name': 'apple', 'price': 10}, {'name': 'banana', 'price': 5}]
  assert sort_list([{'name': 'carrot', 'price': 7}, {'name': 'apple', 'price': 10}, {'name': 'banana', 'price': 5}], 'name') == [{'name': 'apple', 'price': 10}, {'name': 'banana', 'price': 5}, {'name': 'carrot', 'price': 7}]
output: def sort_list(dict_list, key):
      return sorted(dict_list, key=lambda x: x[key])