input: Write a function to sort an array of strings by their lengths. Implement a bubble sort algorithm to sort the input list of strings. If the list is empty, return an empty list.
  def sort_by_length(strings):
      for i in range(len(strings) - 1):
          for j in range(i + 1, len(strings)):
              if len(strings[i]) > len(strings[j]):
                  strings[i], strings[j] = strings[j], strings[i]
      return strings
  
  assert sort_by_length(["cat", "dog", "apple", "banana"])==["cat", "dog", "apple", "banana"]
  assert sort_by_length(["aa", "b", "aaa", "bb"])==["b", "aa", "bb", "aaa"]
  assert sort_by_length(["hello", "the", "world"])==["the", "world", "hello"]
  assert sort_by_length(["abc", "a", "ab"])==["a", "ab", "abc"]
  assert sort_by_length([])==[]
output: def sort_by_length(strings):
      for i in range(len(strings) - 1):
          for j in range(i + 1, len(strings)):
              if len(strings[i]) > len(strings[j]):
                  strings[i], strings[j] = strings[j], strings[i]
      return strings