Implementation of MergeSort in JS