Refactor a bit into calls to bounded_inplace_merge and bounded_merge.