input: Write a function that takes a list of dictionaries, where each dictionary represents an object with multiple attributes, and a string representing the attribute by which to sort the list. The function should return the list of objects sorted by the specified attribute.
  
  ### Function Implementation:
  
  def sort_by_attr(objects, attr):
      return sorted(objects, key=lambda item: item[attr])
  
  
  ### Test Cases:
  
  # Test case 1
  input1 = [{"name": "Alice", "age": 20}, {"name": "Bob", "age": 21}]
  output1 = sort_by_attr(input1, "age")
  assert output1 == [{"name": "Alice", "age": 20}, {"name": "Bob", "age": 21}]
  
  # Test case 2
  input2 = [{"name": "Charlie", "age": 25}, {"name": "David", "age": 18}, {"name": "Eve", "age": 30}]
  output2 = sort_by_attr(input2, "age")
  assert output2 == [{"name": "David", "age": 18}, {"name": "Charlie", "age": 25}, {"name": "Eve", "age": 30}]
  
  # Test case 3
  input3 = [{"name": "Grace", "height": 5.5}, {"name": "Frank", "height": 6.0}, {"name": "Henry", "height": 5.1}]
  output3 = sort_by_attr(input3, "height")
  assert output3 == [{"name": "Henry", "height": 5.1}, {"name": "Grace", "height": 5.5}, {"name": "Frank", "height": 6.0}]
  
output: def sort_by_attr(objects, attr):
      return sorted(objects, key=lambda item: item[attr])