Implement mergesort