input: Write a function to sort a list of strings by their lengths.
  assert sort_by_length(['test', 'sample', 'hello', 'world'])==['test', 'hello', 'world', 'sample']
  assert sort_by_length(['apple', 'pie', 'banana', 'kiwi'])==['pie', 'kiwi', 'apple', 'banana']
  assert sort_by_length(['a', 'ab', 'abc', 'abcd'])==['a', 'ab', 'abc', 'abcd']
output: def sort_by_length(strings):
      return sorted(strings, key=len)