@ts-java/comparator
Version: 
A pure Typescript implementation of the Java `Comparator` functional interface.
22 lines (19 loc) • 855 B
TypeScript
import { Comparator } from './index.js';
/**
 * A comparator that compares two strings lexographically, eliminating case differences by calling toUpperCase().toLowerCase() on each Unicode code point.
 *
 * This Comparator does _not_ take locale into account and will result in an unsatisfactory ordering for certain locales. If locale-sensitive comparison is required,
 * use {@link Intl.Collator} or {@link String.localeCompare} with a proper locale instead.
 *
 * @see {@link Intl.Collator}
 * @see {@link String.localeCompare}
 * @example
 * ```typescript
 * const strings = ['Alpha', 'bravo', 'alpha', 'charlie', 'Bravo']
 * strings.toSorted(
 *  CASE_INSENSITIVE_ORDER.compare
 * ); // ['Alpha', 'alpha', 'bravo', 'Bravo', 'charlie']
 * ```
 */
declare const CASE_INSENSITIVE_ORDER: Readonly<Comparator<string>>;
export { CASE_INSENSITIVE_ORDER };