src/operator/merge-sort.js
function sort (arr, lo, hi, sortFn) {
    if (hi === lo) { return arr; }

    const mid = lo + Math.floor((hi - lo) / 2);
    sort(arr, lo, mid, sortFn);
    sort(arr, mid + 1, hi, sortFn);
    merge(arr, lo, mid, hi, sortFn);

    return arr;
}
function sort (arr, lo, hi, sortFn) {
    if (hi === lo) { return arr; }

    const mid = lo + Math.floor((hi - lo) / 2);
    sort(arr, lo, mid, sortFn);
    sort(arr, mid + 1, hi, sortFn);
    merge(arr, lo, mid, hi, sortFn);

    return arr;
}
function sort ( arr , lo , hi , sortFn ) { if ( hi === lo ) { return arr ; } const mid = lo + Math . floor ( ( hi - lo ) / 2 ) ; sort ( arr , lo , mid , sortFn ) ; sort ( arr , mid + 1 , hi , sortFn ) ; merge ( arr , lo , mid , hi , sortFn ) ; return arr ; }
The helper function for merge sort which would be called
recursively for sorting the array halves.

@param {Array} arr - The target array which needs to be sorted.
@param {number} lo - The starting index of the array half.
@param {number} hi - The ending index of the array half.
@param {Function} sortFn - The sort function.
@return {Array} Returns the target array itself.
The helper function for merge sort which would be called recursively for sorting the array halves .