Optimize BatchTypeSorter.