declare type IOrder = 1 | -1; export interface IComparer { (a: any, b: any, order: IOrder): number; } export interface ISortInstanceOptions { comparer?: IComparer; inPlaceSorting?: boolean; } export interface ISortByFunction { (prop: T): any; } export declare type ISortBy = keyof T | ISortByFunction | (keyof T | ISortByFunction)[]; export interface ISortByAscSorter extends ISortInstanceOptions { asc: boolean | ISortBy; } export interface ISortByDescSorter extends ISortInstanceOptions { desc: boolean | ISortBy; } export declare type ISortByObjectSorter = ISortByAscSorter | ISortByDescSorter; interface IFastSort { /** * Sort array in ascending order. * @example * sort([3, 1, 4]).asc(); * sort(users).asc(u => u.firstName); * sort(users).asc([ * u => u.firstName, * u => u.lastName, * ]); */ asc(sortBy?: ISortBy | ISortBy[]): T[]; /** * Sort array in descending order. * @example * sort([3, 1, 4]).desc(); * sort(users).desc(u => u.firstName); * sort(users).desc([ * u => u.firstName, * u => u.lastName, * ]); */ desc(sortBy?: ISortBy | ISortBy[]): T[]; /** * Sort array in ascending or descending order. It allows sorting on multiple props * in different order for each of them. * @example * sort(users).by([ * { asc: u => u.score }, * { desc: u => u.age }, * ]); */ by(sortBy: ISortByObjectSorter | ISortByObjectSorter[]): T[]; } export declare function createNewSortInstance(opts: ISortInstanceOptions & { inPlaceSorting?: false; }): (arrayToSort: readonly T[]) => IFastSort; export declare function createNewSortInstance(opts: ISortInstanceOptions): (arrayToSort: T[]) => IFastSort; export declare const defaultComparer: (a: any, b: any, order: any) => number; export declare const sort: (arrayToSort: readonly T[]) => IFastSort; export declare const inPlaceSort: (arrayToSort: T[]) => IFastSort; export {};