input: Write a function to sort a list of string based on their lengths in non-decreasing order. The function should return the sorted list. Ensure that the function works for an empty list as well.
  
  assert sort_by_length(["cat", "dog", "apple", "banana"])==["cat", "dog", "apple", "banana"]
  assert sort_by_length(["python", "java", "c", "ruby"])==["c", "java", "ruby", "python"]
  assert sort_by_length([])==[]
  assert sort_by_length(["apple"])==["apple"]
  assert sort_by_length(["longstring", "short"])==["short", "longstring"]
output: def sort_by_length(strings):
      return sorted(strings, key=len)