function uniqueSort(nodes) {
    nodes = nodes.filter((node, i, arr) => !arr.includes(node, i + 1));
    nodes.sort((a, b) => {
        const relative = compareDocumentPosition(a, b);
        if (relative & DocumentPosition.PRECEDING) {
            return -1;
        }
        else if (relative & DocumentPosition.FOLLOWING) {
            return 1;
        }
        return 0;
    });
    return nodes;
}
/**
 * Sort an array of nodes based on their relative position in the document and
 * remove any duplicate nodes. If the array contains nodes that do not belong to
 * the same document, sort order is unspecified.
 *
 * @category Helpers
 * @param nodes Array of DOM nodes.
 * @returns Collection of unique nodes, sorted in document order.
 */
Sort an array of nodes based on their relative position in the document and
remove any duplicate nodes. If the array contains nodes that do not belong to
the same document, sort order is unspecified.

@category Helpers
@param nodes Array of DOM nodes.
@returns Collection of unique nodes, sorted in document order.
Sort an array of nodes based on their relative position in the document and remove any duplicate nodes . If the array contains nodes that do not belong to the same document sort order is unspecified . @category Helpers @param nodes Array of DOM nodes . @returns Collection of unique nodes sorted in document order .
function uniqueSort(nodes) {
    nodes = nodes.filter((node, i, arr) => !arr.includes(node, i + 1));
    nodes.sort((a, b) => {
        const relative = compareDocumentPosition(a, b);
        if (relative & DocumentPosition.PRECEDING) {
            return -1;
        }
        else if (relative & DocumentPosition.FOLLOWING) {
            return 1;
        }
        return 0;
    });
    return nodes;
}
function uniqueSort ( nodes ) { nodes = nodes . filter ( ( node , i , arr ) => ! arr . includes ( node , i + 1 ) ) ; nodes . sort ( ( a , b ) => { const relative = compareDocumentPosition ( a , b ) ; if ( relative & DocumentPosition . PRECEDING ) { return - 1 ; } else if ( relative & DocumentPosition . FOLLOWING ) { return 1 ; } return 0 ; } ) ; return nodes ; }
Sort an array of nodes based on their relative position in the document and
 remove any duplicate nodes.
Sort an array of nodes based on their relative position in the document and remove any duplicate nodes .