complete the insertion sort algorithm