Start sharing components as a team!Share components as a team!Join Bit to build your applications faster.Get Started Free

ascend

v0.26.1arrow_drop_down
v0.26.1
STATUS
Passing
DOWNLOADS
26
LICENSE
MIT
VISIBILITY
Public
PUBLISHED
7 months ago
SIZE
947 B
subject
Makes an ascending comparator function out of a function that returns a value that can be compared with `<` and `>`.
1 contributor
Use ascend in your project ?
Copied
npm i @bit/ramda.ramda.ascend
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.dev
Component Example
React
React
Vue
Angular
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';
revert changes
reload
toggle layout
maximize
sort(byAge, people);
modifieddraft
chevron_left
chevron_right
ascend (
fn:Function,
a:*,
b:*
) : Number

Makes an ascending comparator function out of a function that returns a value that can be compared with < and >.

Example
const byAge = R.ascend(R.prop('age'));
     const people = [
       { name: 'Emma', age: 70 },
       { name: 'Peter', age: 78 },
       { name: 'Mikhail', age: 62 },
     ];
     const peopleByYoungestFirst = R.sort(byAge, people);
       //=> [{ name: 'Mikhail', age: 62 },{ name: 'Emma', age: 70 }, { name: 'Peter', age: 78 }]
Arguments
fn: Function

A function of arity one that returns a value that can be compared

a: *

The first item to be compared.

b: *

The second item to be compared.

Returns
Number

`-1` if fn(a) < fn(b), `1` if fn(b) < fn(a), otherwise `0`