Don't allow scratch arrays used by mergeSort to grow unbounded.

Pre-allocate before sorting, and trim after.
Merge pull request #1750 from AnalyticalGraphicsInc/compactMergeSortScratchArrays

Don't allow scratch arrays used by mergeSort to grow unbounded.