Completed insertion sort