Update R.sortBy to accept Ord, per documentation

http://ramdajs.com/docs/#sortBy
This commit is contained in:
Matt DeKrey
2017-04-05 07:30:50 -05:00
parent 742cb488d6
commit c0577e2ff8
2 changed files with 21 additions and 3 deletions
+3 -3
View File
@@ -1,6 +1,6 @@
// Type definitions for ramda
// Project: https://github.com/donnut/typescript-ramda
// Definitions by: Erwin Poeze <https://github.com/donnut>
// Definitions by: Erwin Poeze <https://github.com/donnut>, Matt DeKrey <https://github.com/mdekrey>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare var R: R.Static;
@@ -1402,8 +1402,8 @@ declare namespace R {
/**
* Sorts the list according to a key generated by the supplied function.
*/
sortBy<T>(fn: (a: any) => string, list: T[]): T[];
sortBy(fn: (a: any) => string): <T>(list: T[]) => T[];
sortBy<T>(fn: (a: any) => Ord, list: T[]): T[];
sortBy(fn: (a: any) => Ord): <T>(list: T[]) => T[];
/**
* Splits a string into an array of strings based on the given
+18
View File
@@ -1617,6 +1617,24 @@ matchPhrases(['foo', 'bar', 'baz']);
R.path(testPath)(testObj); //=> 2
}
() => {
var sortByAgeDescending = R.sortBy(R.compose(R.negate, R.prop('age')));
var alice = {
name: 'ALICE',
age: 101
};
var bob = {
name: 'Bob',
age: -10
};
var clara = {
name: 'clara',
age: 314.159
};
var people = [clara, bob, alice];
sortByAgeDescending(people); //=> [alice, bob, clara]
}
() => {
var sortByNameCaseInsensitive = R.sortBy(R.compose(R.toLower, R.prop('name')));
var alice = {