input: Write a function to sort an array using the insertion sort algorithm. The function should take a list as input and return the sorted list.
  
  def insertion_sort(list):
      for i in range(1,len(list)):
          key = list[i]
          j = i - 1
          while j>=0 and key < list[j]:
              list[j+1] = list[j]
              j-=1
          list[j+1] = key
      return list
  
  assert insertion_sort([5, 3, 1, 4, 2])==[1, 2, 3, 4, 5]
  assert insertion_sort([9, 2, 7, 1, 8])==[1, 2, 7, 8, 9]
  assert insertion_sort([10, 20, 3, 30, 15])==[3, 10, 15, 20, 30]
  assert insertion_sort([1])==[1]
  assert insertion_sort([])==[]
output: def insertion_sort(list):
      for i in range(1,len(list)):
          key = list[i]
          j = i - 1
          while j>=0 and key < list[j]:
              list[j+1] = list[j]
              j-=1
          list[j+1] = key
      return list