Moved the insertion sort algorithm to it's own method.