def insert(l, key_index): i = key_index key = l[i] # remember what was in the ith position j = i - 1 # look in positions to the left of i while j >= 0 and l[j] > key: l[j + 1] = l[j] j -= 1 l[j + 1] = key def insertion_sort(the_list): n = len(the_list) # how many items to sort for i in range(1, n): insert(the_list, i) grade_list = [89, 45, 85, 81, 77, 94, 22, 79, 92, 91] insertion_sort(grade_list) print(grade_list)