Added a more space efficient version of mergesort