Hex Core JS
    Preparing search index...

    Function compareMultiLevel

    Returns a comparison function that compares two arrays of values with the given comparison function(s) for multi- level sorting. Compares values from each array pair-wise.

    If the lengths of the two arrays (aValues and bValues) do not match or if the lengths of the two arrays and comparisonFunctions (if is an array) do not match.

    Lengths of the two arrays (aValues and bValues) and comparisonFunctions (if is an array) must match.

    For usage with arrays of objects, use compareObjects.

    const data = ["100x20", "100x50", "20x200"];
    const compare = compareMultiLevel(compareNumbersAsc(), (e) => e.split("x").map((e) => parseInt(e)));
    data.sort(compare);
    // ["20x200", "100x20", "100x50"]
    function parse(s: string) {
    const [c, n] = s.split(":");
    return [parseInt(n), c];
    }

    const data = ["a:100", "z:100", "c:20"];
    const compare = compareMultiLevel([compareNumbersAsc(), compareStringsDesc()], parse);
    data.sort(compare);
    // ["c:20", "z:100", "a:100"]

    The comparison function or functions to use to compare each pair of values.

    A function to map the input values to the values for comparison. Required when T is not an array type.