input: Write a function to implement the insertion sort algorithm in Python. The function should take a list of integers and return the list sorted in non-decreasing order.
  assert insertion_sort([5, 2, 9, 1, 5, 6]) == [1, 2, 5, 5, 6, 9]
  assert insertion_sort([3, 8, 2, 1, 5]) == [1, 2, 3, 5, 8]
  assert insertion_sort([10, 20, 30, 40]) == [10, 20, 30, 40]
  assert insertion_sort([]) == []
  assert insertion_sort([-1, -5, -3, -2]) == [-5, -3, -2, -1]
output: def insertion_sort(arr):
      for i in range(1, len(arr)):
          key = arr[i]
          j = i - 1
          while j >= 0 and key < arr[j]:
              arr[j + 1] = arr[j]
              j -= 1
          arr[j + 1] = key
      return arr