How to use the sortBy function from ramda

Find comprehensive JavaScript ramda.sortBy code examples handpicked from public code repositorys.

768
769
770
771
772
773
774
775
776
777
if (settings.isParticipantAuthenticationEnabled) {
  verifyParticipantAuthentication({ auth, authenticationMode: settings.authenticationMode, id, participants })
}

return settings.isFeedbackChannelActive
  ? sortBy(
      (o) => (o.resolvedAt ? -dayjs(o.resolvedAt).unix() : -dayjs(o.createdAt).unix()),
      feedbacks.filter((feedback) => feedback.published)
    )
  : []
fork icon12
star icon32
watch icon5

42
43
44
45
46
47
48
49
50
51
52
53
  } //delete _dbug.tt.iter;


  if(Object.keys(nodeScore)<9)log({nodeScore})
  _arr.normalizeMut(nodeScore,null,2)
  if(Object.keys(nodeScore)<9)log({nodeScore})
  return R.sortBy(x=>-x[1],Object.entries(nodeScore))
    .map(([t,e],i)=>({team:t,eigenValue:e,eigenRank:i}));
}


_score.forQuest=(teams,{type,value,color}={})=>{
fork icon1
star icon5
watch icon0

188
189
190
191
192
193
194
195
196
197
// Pick the instantiate function
//

const initSelector = R.pipe(
  R.filter((c) => c.label === 'default' || c.label === 'new'),
  R.sortBy((c) => c.args.length),
  i => R.head(i),
  (i) => i ? i.selector : undefined,
)(contractFile.V3.spec.constructors)
if (!initSelector) {
fork icon1
star icon0
watch icon1

+ 339 other calls in file

101
102
103
104
105
106
107
108
109
110
sortBy(
  ({ dueDate }) =>
    dueDate ? new Date(dueDate.replace(/-/g, '/')).getTime() : 0,
  Object.values(vesselsInput).map(({ shippers, ...rest }) => ({
    ...rest,
    shippers: sortBy(
      ({ shipperName }) => shipperName,
      Object.values(shippers).map(({ unpaids, ...rest2 }) => ({
        ...rest2,
        unpaids: sortBy(({ invoiceId }) => invoiceId, Object.values(unpaids)),
fork icon0
star icon0
watch icon1

+ 17 other calls in file

115
116
117
118
119
120
121
122
123
124

const smartestStudent = R.compose(
    R.head,
    R.pluck(0),
    R.reverse,
    R.sortBy(R.prop(1)),
    R.zip);

let result = smartestStudent(students, grades); //-> 'Turing'
assert.equal(result, 'Turing');
fork icon0
star icon0
watch icon1

+ 2 other calls in file

48
49
50
51
52
53
54
55
56
57
readCsvFile(`${path}/venmo.csv`).then(parseVenmo).then((venmoFacts) => {
  const bankFacts = [...citiFacts, ...mvcuFacts, ...mvcuOldFacts, ...venmoFacts];
  const existingIds = {};
  resolve(R.compose(
    R.reverse,
    R.sortBy(R.prop('timestamp')),
    R.reject(R.isNil),
    R.map((fact) => {
      const id = computeFactId(fact);
      if (existingIds[id]) {
fork icon0
star icon0
watch icon0

+ 3 other calls in file

4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
* @param {Array} list The list to sort.
* @return {Array} A new list sorted by the keys generated by `fn`.
* @example
*
*      var sortByFirstItem = R.sortBy(R.prop(0));
*      var sortByNameCaseInsensitive = R.sortBy(R.compose(R.toLower, R.prop('name')));
*      var pairs = [[-1, 1], [-2, 2], [-3, 3]];
*      sortByFirstItem(pairs); //=> [[-3, 3], [-2, 2], [-1, 1]]
*      var alice = {
*        name: 'ALICE',
fork icon0
star icon0
watch icon0

+ 35 other calls in file

233
234
235
236
237
238
239
240
241
242
243
};


//  build :: [String] -> String
var build =
R.pipe(R.map(filenameToIdentifier),
       R.sortBy(R.identity),
       R.converge(R.concat,
                  R.pipe(createDependencyGraph,
                         orderDependencies,
                         R.map(getModifiedSource),
fork icon0
star icon0
watch icon0

537
538
539
540
541
542
543
544
545
546
547
548
549
550




var sortByFirstItem = R.sortBy(R.prop(0));
log(sortByFirstItem([[-1, 1], [-2, 2], [-3, 3]]));


var sortByNameCaseInsensitive = R.sortBy(
  R.compose(R.toLower, R.prop('name'))
);


var sortByAge = R.sortBy(R.prop('age'))
fork icon0
star icon0
watch icon0

+ 29 other calls in file

190
191
192
193
194
195
196
197
198
199
const finalPopulation = step(initialPopulation, 0)

const best = R.compose(
  R.head,
  R.reverse,
  R.sortBy(R.curry(fitness)(target))
)(finalPopulation)

console.log('BEST')
console.log('chromosome:', best)
fork icon0
star icon0
watch icon0

+ 2 other calls in file

400
401
402
403
404
405
406
407
408

  return data
}

const printDiskUsage = function (sizes) {
  const bySize = R.sortBy(R.prop('1'))

  return console.log(bySize(R.toPairs(sizes)))
}
fork icon0
star icon0
watch icon0

250
251
252
253
254
255
256
257
258
259
     * @typedef {Object.<string, any>} Entity
     * @param {string} by sorting column
     * @param {Entity|Entity[]} input
     * @returns {Promise<Entity[]>}
     */
    sort = (by) => async (input) => R.sortBy(R.prop(by))(toArray(input))
}


module.exports = RecommendationService
fork icon0
star icon0
watch icon0

12691
12692
12693
12694
12695
12696
12697
12698
12699
12700
* @param {Function} fn
* @param {Array} list The list to sort.
* @return {Array} A new list sorted by the keys generated by `fn`.
* @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')));
fork icon0
star icon0
watch icon2

+ 7 other calls in file

81
82
83
84
85
86
87
88
89
90
    feature.selectorId = uuidv4();
    if (feature.status === 'failed') {
        failedFeatures.push(feature);
    }
});
failedFeatures = R.sortBy(R.prop('uri'), failedFeatures);
features = R.sortBy(R.prop('uri'), features);
const stepsSummary = [];
const scenarios = [];
const isCucumber2 = features.every(function (feature) {
fork icon0
star icon0
watch icon0

88
89
90
91
92
93
94
95
96
97
    dateNow = prayers_lib_1.DateUtil.getNowTime();
else
    dateNow = date;
if (dateNow > getPrayerEndPeriond() || dateNow < getPrayerStartPeriod())
    return null;
let orderByFn = ramda.sortBy(ramda.prop('prayerTime'));
let upcomingPrayer = null;
let fardhPrayers = prayerlib.PrayersTypes.filter((n) => n.prayerType === prayerlib.PrayerType.Fardh);
let todayPrayers = getPrayersByDate(dateNow);
if (!(0, prayers_lib_1.isNullOrUndefined)(todayPrayers)) {
fork icon0
star icon0
watch icon0

56
57
58
59
60
61
62
63
64
65
    });    


}, 20);

const result = R.sortBy(x => -x, monkeys.map(x => x.counter));

U.log('results', result);

return result[0] * result[1];
fork icon0
star icon0
watch icon0

64
65
66
67
68
69
70
71
72
73

U.logf('sizes', sizes);

const total = sizes['/'];

const sortedSizes = R.sortBy(R.identity, R.values(sizes));

const result = sortedSizes.find(x => total - x < 40000000);

return result;
fork icon0
star icon0
watch icon0

Other functions in ramda

Sorted by popularity

function icon

ramda.clone is the most popular function in ramda (30311 examples)