urdu-text-utils
Version:
Comprehensive Urdu NLP & text processing toolkit: normalization, Roman Urdu transliteration, stop words, script detection, digits, diacritics (aerab), sorting, search, and statistics. Zero dependencies, ESM + CJS.
20 lines (19 loc) • 695 B
TypeScript
/**
* Comparator for Urdu strings, usable directly in `Array.prototype.sort`.
* Diacritics and Unicode variants are folded first, so spelling noise does not
* change the order.
*/
export declare function compareUrdu(a: string, b: string): number;
export interface SortOptions<T> {
/** Sort descending. Default `false`. */
descending?: boolean;
/** Read the sort key out of each item, for sorting objects. */
getText?: (item: T) => string;
}
/**
* Sort strings in Urdu alphabetical order.
*
* @example
* sortUrdu(["گل", "آم", "بادام"]) // ["آم", "بادام", "گل"]
*/
export declare function sortUrdu<T>(items: readonly T[], options?: SortOptions<T>): T[];