input: Write a python function to sort a list of strings by their lengths.
  assert sort_by_length(["cat", "dog", "apple", "banana"]) == ["cat", "dog", "apple", "banana"]
  assert sort_by_length(["elephant", "dog", "apple", "banana"]) == ["dog", "apple", "banana", "elephant"]
  assert sort_by_length(["a", "abcd", "abc", "ab"]) == ["a", "ab", "abc", "abcd"]
output: def sort_by_length(lst):
      return sorted(lst, key=len)