Implementation of Mergesort that doesn't blow up the stack.