Insertion Sort
Here is a description of insertion sort:
Input: A list of integers.
Output: The list is sorted.
Assume that the sub-list of just one integer at index 0 is sorted
for each index J of the list from 1 to length-1
Insert the integer at index J into the sorted sub-list.
Do this by repeatedly swapping it with its neighbor to the left until it is in the correct place.
It is in the correct place when its left neighbor is smaller than it, or if there is no left neighbor.
Here is another list to practice on:
Why does the index J start at 1?
Why does the index J end at length-1?