input: Write a function that takes a list of dictionaries and an attribute name, then returns a list of the dictionaries sorted by 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": "Charlie", "age": 18}, {"name": "David", "age": 19}], "name")==[{"name": "Charlie", "age": 18}, {"name": "David", "age": 19}]
output: def sort_by_attr(objects, attr):
   return sorted(objects, key=lambda item: item[attr])