jstests/aggregation/extras/utils.js
/**
 * Returns true if both 'al' and 'ar' are arrays of the same length with the same elements.
 * Order of the elements is significant only in the top-level arrays.
 *
 * Element comparison uses the anyEq function recursively, which allows for comparing of nested
 * arrays ignoring the elements' order.
 *
 * Use this function if the arguments have nested arrays and the elements' order is significant at
 * the top-level and insignificant for the nested arrays.
 */
Returns true if both 'al' and 'ar' are arrays of the same length with the same elements.
Order of the elements is significant only in the top-level arrays.

Element comparison uses the anyEq function recursively, which allows for comparing of nested
arrays ignoring the elements' order.

Use this function if the arguments have nested arrays and the elements' order is significant at
the top-level and insignificant for the nested arrays.
Returns true if both ' al ' and ' ar ' are arrays of the same length with the same elements . Order of the elements is significant only in the top - level arrays . Element comparison uses the anyEq function recursively which allows for comparing of nested arrays ignoring the elements ' order . Use this function if the arguments have nested arrays and the elements ' order is significant at the top - level and insignificant for the nested arrays .
function orderedArrayEq(al, ar, verbose = false, fieldsToSkip = []) {
    if (al.length != ar.length) {
        if (verbose)
            print(`orderedArrayEq:  array lengths do not match ${tojson(al)}, ${tojson(ar)}`);
        return false;
    }
    for (let i = 0; i < al.length; ++i) {
        if (!anyEq(al[i], ar[i], verbose, null, fieldsToSkip))
            return false;
    }
    return true;
}
function orderedArrayEq ( al , ar , verbose = false , fieldsToSkip = [ ] ) { if ( al . length != ar . length ) { if ( verbose ) print ( ` ${ tojson ( al ) } ${ tojson ( ar ) } ` ) ; return false ; } for ( let i = 0 ; i < al . length ; ++ i ) { if ( ! anyEq ( al [ i ] , ar [ i ] , verbose , null , fieldsToSkip ) ) return false ; } return true ; }
Returns true if both 'al' and 'ar' are arrays of the same length with the same elements.
Returns true if both ' al ' and ' ar ' are arrays of the same length with the same elements .