sortByProp
See original GitHub issueIs your feature request related to a problem? Please describe.
Sorts the list according to the supplied prop
Describe the solution you’d like
const sortByFirstItem = R.sortByProp(0);
const pairs = [[-1, 1], [-2, 2], [-3, 3]];
sortByFirstItem(pairs); //=> [[-3, 3], [-2, 2], [-1, 1]]
const sortByName = R.sortByProp('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];
sortByName(people); //=> [alice, bob, clara]
Describe alternatives you’ve considered
Additional context
Original issue: https://github.com/char0n/ramda-adjunct/issues/945 Blocked by #1240. This function should be implemented as a specialization of sortByPath
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
sortByProp and sortByPath and orderByProp and ... - GitHub
I'm inclined to wonder, would you be interested in a set of functions (similar to lodash's sortBy and orderBy) which could sort an...
Read more >sortByProps.js - Documentation
sortByProps.js · import { reduce, either, curry, prop, sort, comparator, map, lt } from 'ramda'; · /** · * Sort a list of...
Read more >sort-by-typescript - npm
sortBy(prop ). To sort by name in ascending order: customers.sort(sortBy('name')); /* Result [ { id: 1, name: 'Alex', age: 45, ...
Read more >How to Use Supercharged Sorts in JavaScript - freeCodeCamp
Let's start by trying to make a generic sortByProp function. That will take a property name, and two objects, and compare them.
Read more >SortBy | React InstantSearch Hooks - Algolia
type: SortByProps['items']. Required. A list of different indices to choose from. JSX. Copy. 1 2 3 4 5 6 7, <SortBy items={[ {...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
After a loooooong time, I finally created the PR.
Fun fact: I created the branch and did all changes after merged
sortByPath
PR, but I forgot to create the actual PR 🤦♂️@tauantcamargo I guess he’s not. Feel free to issue a PR.