input: Write a function to sort an array of strings by their length in ascending order. Implement the sorting algorithm using a nested loop to compare and swap elements. If the input array is empty, return an empty array.
  
  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(["longword", "short", "medium"])==["short", "medium", "longword"]
  assert sort_by_length(["a", "bb", "ccc", "dddd"])==["a", "bb", "ccc", "dddd"]
  assert sort_by_length([])==[]
  assert sort_by_length(["single"])==["single"]
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