lib/util-x.js
function merge(left, right, comparison) {
        var result = [],
            next = 0,
            sComp;

        result.length = left.length + right.length;
        while (left.length && right.length) {
            sComp = sortCompare(left, right);
            if (typeof sComp !== 'number') {
                if (comparison(left[0], right[0]) <= 0) {
                    if ($hasOwn(left, 0)) {
                        result[next] = left[0];
                    }

                    pShift.call(left);
                } else {
                    if ($hasOwn(right, 0)) {
                        result[next] = right[0];
                    }

                    pShift.call(right);
                }
            } else if (sComp <= 0) {
                if ($hasOwn(left, 0)) {
                    result[next] = left[0];
                }

                pShift.call(left);
            } else {
                if ($hasOwn(right, 0)) {
                    result[next] = right[0];
                }

                pShift.call(right);
            }

            next += 1;
        }

        while (left.length) {
            if ($hasOwn(left, 0)) {
                result[next] = left[0];
            }

            pShift.call(left);
            next += 1;
        }

        while (right.length) {
            if ($hasOwn(right, 0)) {
                result[next] = right[0];
            }

            pShift.call(right);
            next += 1;
        }

        return result;
    }
function merge(left, right, comparison) {
        var result = [],
            next = 0,
            sComp;

        result.length = left.length + right.length;
        while (left.length && right.length) {
            sComp = sortCompare(left, right);
            if (typeof sComp !== 'number') {
                if (comparison(left[0], right[0]) <= 0) {
                    if ($hasOwn(left, 0)) {
                        result[next] = left[0];
                    }

                    pShift.call(left);
                } else {
                    if ($hasOwn(right, 0)) {
                        result[next] = right[0];
                    }

                    pShift.call(right);
                }
            } else if (sComp <= 0) {
                if ($hasOwn(left, 0)) {
                    result[next] = left[0];
                }

                pShift.call(left);
            } else {
                if ($hasOwn(right, 0)) {
                    result[next] = right[0];
                }

                pShift.call(right);
            }

            next += 1;
        }

        while (left.length) {
            if ($hasOwn(left, 0)) {
                result[next] = left[0];
            }

            pShift.call(left);
            next += 1;
        }

        while (right.length) {
            if ($hasOwn(right, 0)) {
                result[next] = right[0];
            }

            pShift.call(right);
            next += 1;
        }

        return result;
    }
function merge ( left , right , comparison ) { var result = [ ] , next = 0 , sComp ; result . length = left . length + right . length ; while ( left . length && right . length ) { sComp = sortCompare ( left , right ) ; if ( typeof sComp !== 'number' ) { if ( comparison ( left [ 0 ] , right [ 0 ] ) <= 0 ) { if ( $hasOwn ( left , 0 ) ) { result [ next ] = left [ 0 ] ; } pShift . call ( left ) ; } else { if ( $hasOwn ( right , 0 ) ) { result [ next ] = right [ 0 ] ; } pShift . call ( right ) ; } } else if ( sComp <= 0 ) { if ( $hasOwn ( left , 0 ) ) { result [ next ] = left [ 0 ] ; } pShift . call ( left ) ; } else { if ( $hasOwn ( right , 0 ) ) { result [ next ] = right [ 0 ] ; } pShift . call ( right ) ; } next += 1 ; } while ( left . length ) { if ( $hasOwn ( left , 0 ) ) { result [ next ] = left [ 0 ] ; } pShift . call ( left ) ; next += 1 ; } while ( right . length ) { if ( $hasOwn ( right , 0 ) ) { result [ next ] = right [ 0 ] ; } pShift . call ( right ) ; next += 1 ; } return result ; }
merge function for stableSort.
@private
@function merge
@param {ArrayLike} left
@param {ArrayLike} right
@param {Function} comparison
@returns {Array}
merge function for stableSort .