Refactored out similar code for IterativeMergeSort and MergeSort