const identity = (item)=>{
    if (typeof item === "string") {
        return item;
    }
    if (process.env.NODE_ENV !== "production") {
        throw new Error("A `TextExtractor` must be provided to `alphaNumericSort` for lists that do not contain strings");
    }
    return "";
};
/**
 * The default `Intl.Collator` that should be used for sorting large lists.
 *
 * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare#performance
 * @remarks \@since 6.0.0
 */ export const DEFAULT_COLLATOR = new Intl.Collator("en-US", {
    numeric: true,
    caseFirst: "upper"
});
export function alphaNumericSort(list, options = {}) {
    const { compare = DEFAULT_COLLATOR.compare, extractor = identity, descending = false } = options;
    const sorted = list.slice();
    sorted.sort((a, b)=>{
        const aValue = extractor(a);
        const bValue = extractor(b);
        const value1 = descending ? bValue : aValue;
        const value2 = descending ? aValue : bValue;
        return compare(value1, value2);
    });
    return sorted;
}

//# sourceMappingURL=alphaNumericSort.js.map