Function documentOrderComparator

  • Compares the position of the given node against another node in any document.

    Unset elements (e.g. null) are undefined behaviour but the current non-contractural behaviour is to put them at the end of the sorted array. The caller should ensure those elements are removed before sorting.

    Type Parameters

    • T extends Node

    Parameters

    • Optionala: null | T
    • Optionalb: null | T

    Returns number

    const sorted = listOfElements.sort(documentOrderComparator);