input: Write a function to sort an array of strings by their length in non-decreasing order. If two strings have the same length, their order should remain unchanged. The function should modify the array in place and return the sorted array.
  assert sort_by_length(["cat", "dog", "apple", "banana"])==['cat', 'dog', 'apple', 'banana']
  assert sort_by_length(["short", "verylongstring", "medium", "s"])==['s', 'short', 'medium', 'verylongstring']
  assert sort_by_length(["same", "same", "same", "same"])==['same', 'same', 'same', 'same']
  assert sort_by_length([])==[]
output: def sort_by_length(arr):
      arr.sort(key=len)
      return arr