input: Write a function to sort a list of objects by one of their attributes. The function should take two parameters: the list of objects and the attribute name by which to sort.
  
  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": 19}, {"name": "David", "age": 22}], "name") == [{"name": "Charlie", "age": 19}, {"name": "David", "age": 22}]
  assert sort_by_attr([{"name": "Eve", "age": 20}, {"name": "Frank", "age": 20}], "age") == [{"name": "Eve", "age": 20}, {"name": "Frank", "age": 20}]
output: def sort_by_attr(objects, attr):
      return sorted(objects, key=lambda item: item[attr])