mergesort implementation