input: Write a function in Python that takes a list of objects and an attribute name, and returns a list of those objects sorted by that attribute. If the given list is empty, it should return an empty list.
  def sort_by_attr(objects, attr):
      if not objects:
          return []
      return sorted(objects, key=lambda item: item[attr] if attr in item else float('inf'))
  
  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": 19}, {"name": "Dave", "age": 25}, {"name": "Eve", "age": 22}], "age") == [{"name": "Charlie", "age": 19}, {"name": "Eve", "age": 22}, {"name": "Dave", "age": 25}]
  assert sort_by_attr([], "age") == []
  assert sort_by_attr([{"name": "Alice", "age": 20}, {"name": "Bob", "age": 21}], "does_not_exist") == [{"name": "Alice", "age": 20}, {"name": "Bob", "age": 21}]
output: def sort_by_attr(objects, attr):
      if not objects:
          return []
      return sorted(objects, key=lambda item: item[attr] if attr in item else float('inf'))