question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is 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:closed
  • Created 4 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
nolletocommented, Oct 19, 2022

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 🤦‍♂️

1reaction
char0ncommented, Sep 18, 2022

@tauantcamargo I guess he’s not. Feel free to issue a PR.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found