sort ( title : string , ) : < T extends object , Fields extends string , Sortable extends (` - ${ Fields } ` | ` + ${ Fields } ` )[] = (` - ${ Fields } ` | ` + ${ Fields } ` )[] , > ( getter : ( sortable : Sortable ) => Promise < T [] > , ) => ( ... fields : Fields [] , ) => ( comp : ( x : T , y : T ) => number , filter ?: ( elem : T ) => boolean , ) => ( direction : "+" | "-" , trace ?: boolean ) => Promise < void > Returns < T extends object , Fields extends string , Sortable extends (` - ${ Fields } ` | ` + ${ Fields } ` )[] = (` - ${ Fields } ` | ` + ${ Fields } ` )[] , > ( getter : ( sortable : Sortable ) => Promise < T [] > , ) => ( ... fields : Fields [] , ) => ( comp : ( x : T , y : T ) => number , filter ?: ( elem : T ) => boolean , ) => ( direction : "+" | "-" , trace ?: boolean ) => Promise < void > < T extends object , Fields extends string , Sortable extends (` - ${ Fields } ` | ` + ${ Fields } ` )[] = (` - ${ Fields } ` | ` + ${ Fields } ` )[] , > ( getter : ( sortable : Sortable ) => Promise < T [] > , ) : ( ... fields : Fields [] , ) => ( comp : ( x : T , y : T ) => number , filter ?: ( elem : T ) => boolean , ) => ( direction : "+" | "-" , trace ?: boolean ) => Promise < void > Returns ( ... fields : Fields [] , ) => ( comp : ( x : T , y : T ) => number , filter ?: ( elem : T ) => boolean , ) => ( direction : "+" | "-" , trace ?: boolean ) => Promise < void > ( ... fields : Fields [] , ) : ( comp : ( x : T , y : T ) => number , filter ?: ( elem : T ) => boolean , ) => ( direction : "+" | "-" , trace ?: boolean ) => Promise < void > Returns ( comp : ( x : T , y : T ) => number , filter ?: ( elem : T ) => boolean , ) => ( direction : "+" | "-" , trace ?: boolean ) => Promise < void > ( comp : ( x : T , y : T ) => number , filter ?: ( elem : T ) => boolean , ) : ( direction : "+" | "-" , trace ?: boolean ) => Promise < void > Parameters comp : ( x : T , y : T ) => number Optional
filter : ( elem : T ) => boolean Returns ( direction : "+" | "-" , trace ?: boolean ) => Promise < void > ( direction : "+" | "-" , trace ?: boolean ) : Promise < void > Parameters direction : "+" | "-" trace : boolean = false Returns Promise < void >
Validate sorting options.
Test a pagination API supporting sorting options.
You can validate detailed sorting options both asceding and descending orders with multiple fields. However, as it forms a complicate currying function, I recomend you to see below example code before using.
Example