Insertion sort optimized.