input: Write a function to sort an array of strings by their length in non-decreasing order. The function should return the sorted array. If the array is empty, it should return an empty array.
  assert sort_by_length(["cat", "dog", "apple", "banana"])==["cat", "dog", "apple", "banana"]
  assert sort_by_length(["python", "java", "c"])==["c", "java", "python"]
  assert sort_by_length(["hi", "hello", "world"])==["hi", "hi", "world"]
  assert sort_by_length([])==[]
output: def sort_by_length(arr):
      return sorted(arr, key=len)