input: Write a function that takes a list of dictionaries and an attribute name, and returns the list sorted according to the specified attribute.
  
  def sort_by_attr(objects, attr):
   return sorted(objects, key=lambda item: item[attr])
  
  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": "Carol", "age": 28}, {"name": "David", "age": 25}], "name") == [{"name": "Carol", "age": 28}, {"name": "David", "age": 25}]
  assert sort_by_attr([], "age") == []
  assert sort_by_attr([{"name": "Eve", "age": 23}], "age") == [{"name": "Eve", "age": 23}]
output: def sort_by_attr(objects, attr):
   return sorted(objects, key=lambda item: item[attr])