A more performant but less elegant JavaScript implementation of the merge sort algorithm