input: Write a function to sort an array of strings by their length in ascending order using a bubble sort algorithm. The function should take an array of strings as input and return the sorted array.
  assert sort_by_length(["cat", "dog", "apple", "banana"])==["cat", "dog", "apple", "banana"]
  assert sort_by_length(["a", "abc", "ab", "abcd"])==["a", "ab", "abc", "abcd"]
  assert sort_by_length(["hello", "world"])==["world", "hello"]
  assert sort_by_length([])==[]
  assert sort_by_length(["single"])==["single"]
output: def sort_by_length(arr):
      n = len(arr)
      for i in range(n):
          for j in range(0, n-i-1):
              if len(arr[j]) > len(arr[j+1]):
                  arr[j], arr[j+1] = arr[j+1], arr[j]
      return arr