lib/util-x.js
function mergeSort(array, comparefn) {
        var length = array.length,
            middle,
            front,
            back,
            val;

        if (length < 2) {
            val = $slice(array);
        } else {
            middle = ceil(length / 2);
            front = $slice(array, 0, middle);
            back = $slice(array, middle);
            val = merge(mergeSort(front, comparefn), mergeSort(back, comparefn), comparefn);
        }

        return val;
    }
function mergeSort(array, comparefn) {
        var length = array.length,
            middle,
            front,
            back,
            val;

        if (length < 2) {
            val = $slice(array);
        } else {
            middle = ceil(length / 2);
            front = $slice(array, 0, middle);
            back = $slice(array, middle);
            val = merge(mergeSort(front, comparefn), mergeSort(back, comparefn), comparefn);
        }

        return val;
    }
function mergeSort ( array , comparefn ) { var length = array . length , middle , front , back , val ; if ( length < 2 ) { val = $slice ( array ) ; } else { middle = ceil ( length / 2 ) ; front = $slice ( array , 0 , middle ) ; back = $slice ( array , middle ) ; val = merge ( mergeSort ( front , comparefn ) , mergeSort ( back , comparefn ) , comparefn ) ; } return val ; }
mergeSort function for stableSort.
@private
@function mergeSort
@param {ArrayLike} array
@param {Function} comparefn
@returns {Array}
mergeSort function for stableSort .