input: Write a function to sort a list of dictionaries by a given key. The function should take in the list of dictionaries and the key to sort by, and return the sorted list. If the list is empty, the function should return an empty list.
  
  assert sort_list_of_dicts([{'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_list_of_dicts([{'name': 'John', 'age': 25}, {'name': 'Jane', 'age': 22}], 'age') == [{'name': 'Jane', 'age': 22}, {'name': 'John', 'age': 25}]
  assert sort_list_of_dicts([{'a': 1, 'b': 3}, {'a': 2, 'b': 2}], 'b') == [{'a': 2, 'b': 2}, {'a': 1, 'b': 3}]
  assert sort_list_of_dicts([], 'color') == []
output: def sort_list_of_dicts(lst, key):
      return sorted(lst, key=lambda x: x.get(key)) if lst else []