import { defaultExtractor } from "../searching/utils.js";
/**
 * @since 6.2.0
 * @internal
 */ const DEFAULT_EXTRACTOR = defaultExtractor("alphaNumericSort");
/** @since 6.0.0 */ export const DEFAULT_COLLATOR_OPTIONS = {
    numeric: true,
    caseFirst: "upper"
};
/**
 * 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
 * @since 6.0.0
 */ export const DEFAULT_COLLATOR = new Intl.Collator("en-US", DEFAULT_COLLATOR_OPTIONS);
export function alphaNumericSort(list, options = {}) {
    const { compare = DEFAULT_COLLATOR.compare, extractor = DEFAULT_EXTRACTOR, 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