sort-by

v0.9.6arrow_drop_down
v0.9.6
STATUS
Passing
DOWNLOADS
2
VISIBILITY
Public
PUBLISHED
5 years ago
SIZE
842 B
Sorts the list according to the supplied function.
1 contributor
Install sort-by as a package?
Copied
npm i @bit/justin-capalbo.ramda.sort-by
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
sortBy (
fn:Function,
list:Array
) : Array

Sorts the list according to the supplied function.

Example
const sortByFirstItem = R.sortBy(R.prop(0));
     const pairs = [[-1, 1], [-2, 2], [-3, 3]];
     sortByFirstItem(pairs); //=> [[-3, 3], [-2, 2], [-1, 1]]

     const sortByNameCaseInsensitive = R.sortBy(R.compose(R.toLower, R.prop('name')));
     const alice = {
       name: 'ALICE',
       age: 101
     };
     const bob = {
       name: 'Bob',
       age: -10
     };
     const clara = {
       name: 'clara',
       age: 314.159
     };
     const people = [clara, bob, alice];
     sortByNameCaseInsensitive(people); //=> [alice, bob, clara]
Arguments
fn: Function
list: Array

The list to sort.

Returns
Array

A new list sorted by the keys generated by `fn`.

Help and resources