Optimized sorting to 1-time execution.