input: Write a function in Python that takes a list of objects and returns a list of those objects sorted by one of their attributes.
  
  ### Example Function:
  
  def sort_by_attr(objects, attr):
   return sorted(objects, key=lambda item: item[attr])
   
  sort_by_attr([{"name": "Alice", "age": 20}, {"name": "Bob", "age": 21}], "age")
  
  
  ### Example Assertion:
  
  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": 23}, {"name": "David", "age": 22}], "age") == [{"name": "David", "age": 22}, {"name": "Charlie", "age": 23}]
  assert sort_by_attr([{"name": "Eve", "age": 24}, {"name": "Frank", "age": 24}], "age") == [{"name": "Eve", "age": 24}, {"name": "Frank", "age": 24}]
  assert sort_by_attr([], "age") == []
  
  
  This function sorts a list of dictionaries by a specified attribute and returns the sorted list.
output: def sort_by_attr(objects, attr):
   return sorted(objects, key=lambda item: item[attr])