import { defaultExtractor } from "../searching/utils.js";
/**
 * 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 = defaultExtractor("alphaNumericSort"), 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