input: Write a function to sort a list of dictionaries by a specified key in each dictionary. If the key is not present in any dictionary, the function should handle it gracefully. If the list is empty, the function should return an empty list.
  assert sort_list_of_dicts_by_key([{'name': 'Tom', 'age': 25}, {'name': 'John', 'age': 21}, {'name': 'Adam', 'age': 26}], 'age')==[{'name': 'John', 'age': 21}, {'name': 'Tom', 'age': 25}, {'name': 'Adam', 'age': 26}]
  assert sort_list_of_dicts_by_key([{'name': 'Tom', 'age': 25}, {'name': 'John', 'age': 21}, {'name': 'Adam', 'age': 26}], 'name')==[{'name': 'Adam', 'age': 26}, {'name': 'John', 'age': 21}, {'name': 'Tom', 'age': 25}]
  assert sort_list_of_dicts_by_key([{'name': 'Tom', 'age': 25}, {'name': 'John', 'age': 21}, {'name': 'Adam', 'age': 26}], 'nonexistent_key')==[{'name': 'Tom', 'age': 25}, {'name': 'John', 'age': 21}, {'name': 'Adam', 'age': 26}]
  assert sort_list_of_dicts_by_key([], 'age')==[]
  assert sort_list_of_dicts_by_key([{'name': 'Tom', 'age': 25}, {'name': 'John'}], 'age')==[{'name': 'John'}, {'name': 'Tom', 'age': 25}]
output: def sort_list_of_dicts_by_key(lst, key):
      return sorted(lst, key=lambda x: x.get(key) if key in x else float('inf'))