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.
  
  ### Write a function to sort a list of objects by one of their attributes.
  
  
  def sort_by_attr(objects, attr):
      return sorted(objects, key=lambda item: item[attr])
  
  # Assert test cases
  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": 25}, {"name": "Dave", "age": 23}], "name") == [{"name": "Charlie", "age": 25}, {"name": "Dave", "age": 23}]
  assert sort_by_attr([{"name": "Eve", "age": 30}, {"name": "Frank", "age": 30}], "age") == [{"name": "Eve", "age": 30}, {"name": "Frank", "age": 30}]
  assert sort_by_attr([], "age") == []
  
output: def sort_by_attr(objects, attr):
      return sorted(objects, key=lambda item: item[attr])