input: Write a python function to sort a list of dictionaries by a specified attribute.
  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": 22}], "age") == [{"name": "Dave", "age": 22}, {"name": "Charlie", "age": 25}]
  assert sort_by_attr([{"name": "Eve", "score": 90}, {"name": "Frank", "score": 80}], "score") == [{"name": "Frank", "score": 80}, {"name": "Eve", "score": 90}]
output: def sort_by_attr(lst, attr):
      return sorted(lst, key=lambda x: x[attr])