Fixed performance issues with SortInsertActions for large batches.

The way this function was written, a huge number of senseless iterations and comparisons were performed before simply being negated by the && j > lastPos check. By making the loop over the nameList the outermost loop and start at lastPos + 1, CPU usage on large insert batches is significantly reduced and there should be no functional change.