Implement merge sort in JS