Implement merge sort