I loved whole L. Spiro's post, but I have something to correct
Sorting 2 smaller queues is faster than 1 big one.
This is a half truth.
Sorting can take:
- Best Case: O(N)
- Avg. Case: O( N log( N ) )
- Worst Case: O( N^2 )
1. In best case, N/2 + N/2 = N; so in theory it doesn't matter whether it's split or not. But there is the advantage that two containers can be sort in separate threads. So it's a win.
2. In the average case, 2 * (N/2 log(N/2)) > N log(N); having one large container should be faster than sorting two smaller ones (though there remains to be seen whether threading can negate the effect up to certain N)
3. In the worst case, 2 * (N/2)^2 < N^2; which means it's much better to sort two smaller containers than a large one.
In the end you'll have to profile as it is not a golden rule.
Spiro's suggestion of using temporal coherence assumes that most of the time you can get O(N) sorting using insertion sort; thus most likely having two smaller containers should be better (if you perform threading).
Update: Stupid algebra mistake. See lunkhound's post. Avg case is better when dividing and conquering.