comparator

v0.9.6arrow_drop_down
v0.9.6
STATUS
Passing
DOWNLOADS
2
VISIBILITY
Public
PUBLISHED
5 years ago
SIZE
705 B
Makes a comparator function out of a function that reports whether the first element is less than the second.
1 contributor
Install comparator as a package?
Copied
npm i @bit/justin-capalbo.ramda.comparator
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.cloud
Component Example
React
React
Vue
Angular
React Native
Add dependency... help_outline
Just
import
any of the 1 million components
and packages in Bit or NPM to the example.
import Button from '@bit/grommet.grommet.button';
import Lodash from 'lodash';
toggle layout
No preview available
modifieddraft
chevron_left
chevron_right
comparator (
pred:Function
) : Function

Makes a comparator function out of a function that reports whether the first element is less than the second.

Example
const byAge = R.comparator((a, b) => a.age < b.age);
     const people = [
       { name: 'Emma', age: 70 },
       { name: 'Peter', age: 78 },
       { name: 'Mikhail', age: 62 },
     ];
     const peopleByIncreasingAge = R.sort(byAge, people);
       //=> [{ name: 'Mikhail', age: 62 },{ name: 'Emma', age: 70 }, { name: 'Peter', age: 78 }]
Argument
pred: Function

A predicate function of arity two which will return true if the first argument is less than the second, false otherwise

Returns
Function

A Function :: a -> b -> Int that returns `-1` if a < b, `1` if b < a, otherwise `0`

Help and resources