File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed
Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -1528,15 +1528,23 @@ export function sortBy<T>(array: ArrayLike<T>, select: SortSelect<T>): T[] {
15281528 return sort ( array , ( a , b ) => defaultCompare ( select ( a ) as any , select ( b ) as any ) ) ;
15291529}
15301530
1531+ export function sortByFn < T > ( select : SortSelect < T > ) : ( array : ArrayLike < T > ) => T [ ] {
1532+ return array => sortBy ( array , select ) ;
1533+ }
1534+
1535+ export function sortByDescending < T > ( array : ArrayLike < T > , select : SortSelect < T > ) : T [ ] {
1536+ return sort ( array , ( a , b ) => - defaultCompare ( select ( a ) as any , select ( b ) as any ) ) ;
1537+ }
1538+
1539+ export function sortByDescendingFn < T > ( select : SortSelect < T > ) : ( array : ArrayLike < T > ) => T [ ] {
1540+ return array => sortByDescending ( array , select ) ;
1541+ }
1542+
15311543export type SortSelect < T > =
15321544 | ( ( element : T ) => boolean )
15331545 | ( ( element : T ) => number )
15341546 | ( ( element : T ) => string ) ;
15351547
1536- export function sortByFn < T > ( select : SortSelect < T > ) : ( array : ArrayLike < T > ) => T [ ] {
1537- return array => sortBy ( array , select ) ;
1538- }
1539-
15401548export function forEach < T > (
15411549 array : ArrayLike < T > ,
15421550 f : ( element : T , index : number ) => void
You can’t perform that action at this time.
0 commit comments