input: Write a function that sorts a list of dictionaries by a specified attribute of the dictionaries. The function should take a list of dictionaries and the name of the attribute as inputs and return the sorted list.
  
  Input:
  
  [{"name": "Alice", "age": 20}, {"name": "Bob", "age": 21}]
  
  
  Output:
  
  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": 22}, {"name": "Alice", "age": 20}, {"name": "Bob", "age": 21}], "name")==[{"name": "Alice", "age": 20}, {"name": "Bob", "age": 21}, {"name": "Charlie", "age": 22}]
  assert sort_by_attr([], "age")==[]
  
output: def sort_by_attr(objects, attr):
      return sorted(objects, key=lambda item: item[attr])