input: Write a function that takes a list of objects and returns a list of those objects sorted by one attribute specified by the given key. If the list is empty, return an empty list.
  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": "Bob", "age": 21}, {"name": "Alice", "age": 20}], "name")==[{"name": "Alice", "age": 20}, {"name": "Bob", "age": 21}]
  assert sort_by_attr([], "age")==[]
  assert sort_by_attr([{"name": "Charlie", "height": 175}, {"name": "Alice", "height": 160}], "height")==[{"name": "Alice", "height": 160}, {"name": "Charlie", "height": 175}]
  assert sort_by_attr([{"name": "Alice", "height": 160}, {"name": "Charlie", "height": 175}], "name")==[{"name": "Alice", "height": 160}, {"name": "Charlie", "height": 175}]
output: def sort_by_attr(objects, key):
      return sorted(objects, key=lambda x: x.get(key))