input: Write a function to sort an array of strings by their lengths in ascending order. Implement a simple sorting algorithm like selection sort. The function should take a list of strings and return the list sorted by length.
  
  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(["apple", "grape", "cherry", "banana"]) == ["grape", "apple", "cherry", "banana"]
  assert sort_by_length(["verylongword", "short", "long"]) == ["long", "short", "verylongword"]
  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