input: Write a function to return a list of objects sorted by one of their attributes. If the list is empty, the function should return an empty list. The function should accept a list of objects and the name of the attribute to be used for sorting, and it should return the sorted list.
  assert sort_by_attr([{"name": "Alice", "age": 20}, {"name": "Bob", "age": 21}], "age")==[{"name": "Alice", "age": 20}, {"name": "Bob", "age": 21}]
  assert sort_by_attr([{"name": "Charlie", "age": 25}, {"name": "Dave", "age": 22}], "name")==[{"name": "Charlie", "age": 25}, {"name": "Dave", "age": 22}]
  assert sort_by_attr([{"name": "Eve", "age": 19}], "age")==[{"name": "Eve", "age": 19}]
  assert sort_by_attr([], "age")==[]
output: def sort_by_attr(lst, attr):
      if not lst:
          return []
      return sorted(lst, key=lambda x: x.get(attr))