How to use the sortWith function from ramda
Find comprehensive JavaScript ramda.sortWith code examples handpicked from public code repositorys.
GitHub: 18xx-maker/18xx-maker
45 46 47 48 49 50 51 52 53 54 55 56
const colorSort = R.compose( tileColors.indexOf.bind(tileColors), R.prop("color"), R.defaultTo({ color: "other" }) ); const sortTiles = R.sortWith([R.ascend(colorSort)]); setup(); // Startup server
52
51
0
133 134 135 136 137 138 139 140 141 142
}); } if (missingAds.length > 0) { const examples = R.take( numExamples, R.sortWith([R.prop("key"), R.prop("url")], missingAds) ); examples.forEach((example) => { errorMsg += `\n- This was overlooked: ${JSON.stringify( example
14
29
0
GitHub: rajasegar/eax
177 178 179 180 181 182 183 184 185 186
if (files.length !== 0) { data = files.map((f) => { return [f.name, f.size, f.gzipSize, f.brotliSize]; }); const fileSizeSort = R.sortWith([R.descend(R.prop(2))]); data = fileSizeSort(data).map((d) => { const [name, length, gzip, brotli] = d; return [
0
21
0
GitHub: rajasegar/eax
18 19 20 21 22 23 24 25 26 27
}).map((f) => { const stat = fs.readFileSync(f, 'utf-8'); return [f, stat.length, stat.split('\n').length - 1]; }); const fileSizeSort = R.sortWith([R.descend(R.prop(1))]); items = fileSizeSort(items).map((i) => { const [fileName] = i; return fileName.replace(`${folder}/`, '');
0
21
0
22 23 24 25 26 27 28 29 30 31 32
}; const buildEvent = (props, eventData) => setDefaults(R.pick(props, eventData)); const buildOtData = userType => JSON.stringify({ userType }); const sortByCreatedAt = R.sortWith([R.ascend(R.prop('createdAt'))]); const filterByStatus = status => R.find(R.propEq('status', status)); const getImages = R.pick(['startImage', 'endImage']); /** Exports */
12
5
0
GitHub: lilinsong/knownsec
66 67 68 69 70 71 72 73 74 75
if (!usefulMachines) { logger.info(task.id + ' --> ' + null); return Promise.resolve(null); } // 优先使用group能分配上的machine,如果多个machine满足,则优先使用id更小的 const sortMachines = R.sortWith([R.descend(R.prop('group')), R.ascend(R.prop('id'))])(usefulMachines); sortMachines[0].usedCpus ++; return Promise.all([ Machine.update({ 'id': sortMachines[0].id }, { 'usedCpus': sortMachines[0].usedCpus }) .then(res => logger.debug('更新usedCpus成功:', res))
0
3
0
+ 2 other calls in file
138 139 140 141 142 143 144 145 146 147
}; return R.pipe( // find items in same horizontal row R.filter(inBetweenY(nextBlockLabelItem.transform[5], blockLabelItem.transform[5])), R.sortWith([sortTopToBottom, sortLeftToRight]), // sort from top to bottom, left to right R.filter((item) => item.str.trim() !== ''), // remove empty items (is) => (R.length(is) % 2 === 1 ? R.drop(1, is) : is), // remove block label if odd number of items R.map(R.prop('str')), // extract string values from all items R.map(trimEnd(':')), // remove the : at the end of the labels
0
1
0
+ 3 other calls in file
GitHub: alvaro-cuesta/aoc-js
65 66 67 68 69 70 71 72 73 74 75 76
) const sortedFrequency = R.pipe( frequency, R.toPairs, R.sortWith([R.descend(R.nth(1)), R.ascend(R.identity)]), ) const matchAllOverlapping = function* matchAllOverlapping(str, fromRE) { const re = new RegExp(fromRE)
0
1
0
+ 4 other calls in file
63 64 65 66 67 68 69 70 71 72 73 74 75
// const filteredCities = R.filter(filterByWeather, scoredCities); // console.log(R.length(filteredCities)); // const sortedCities = R.sortWith( // [R.descend(city => city.score)], // filteredCities, // );
0
1
0
GitHub: dqmmpb/define-demos
396 397 398 399 400 401 402 403 404 405
var clara = { name: 'clara', age: 40 } var people = [clara, bob, alice]; var ageNameSort = R.sortWith([ R.descend(R.prop('age')), R.ascend(R.prop('name')) ]) log(ageNameSort(people));
0
0
0
+ 9 other calls in file
GitHub: jsdevlib/js-samples
92 93 94 95 96 97 98 99 100 101 102
const topCities = R.pipe( R.map(updateTemperature(KtoF)), R.filter(filterByWeather), R.map(calcScore), R.sortWith([R.descend(city => city.score)]), R.take(10), R.map(cityToArray), R.prepend(interestingProps), table,
0
0
0
+ 5 other calls in file
80 81 82 83 84 85 86 87 88 89
console.log('Detected no known browsers installed') } console.log('') const sortByNameAndMajor = sortWith([ ascend(prop('name')), ascend(prop('majorVersion')), ]) const sortedByNameAndMajorVersion = sortByNameAndMajor(browsers)
0
0
0
22 23 24 25 26 27 28 29 30 31 32
describe('cloudUserCtrl.getAllCloudUsers', () => { beforeAll(done => { converter.fromFile(path.resolve(__dirname, '../../../../run/env/test/seedData/coreDb/cloudUsers.csv'), (err, data) => { KNOWN_TEST_CLOUD_USER_DATA = R.compose( R.sortWith([ R.ascend(R.prop('lastName')), R.ascend(R.prop('firstName')) ]), R.map(R.omit(privateFields)),
0
0
0
+ 2 other calls in file
25 26 27 28 29 30 31 32 33 34 35
return null } // Sort the array by a couple of fields function sortArrayByDateTime(events_array) { const sorted_array = R.sortWith([ R.ascend(R.compose(R.prop('uts'), R.prop('event'))) ]) const result = sorted_array(events_array) return result
0
0
0
7 8 9 10 11 12 13 14 15 16 17 18
arvish.cache.clear() const ENABLED_PROVIDERS = {} torrentSearch.enableProvider('thepiratebay') torrentSearch.enableProvider('Rarbg') const sortBySeedsAndPeers = R.sortWith([R.descend(R.prop('seeds')), R.descend(R.prop('peers'))]) const parseUploadDate = date => date && isBefore(chrono.parseDate(date), Date.now()) ? formatDistance(chrono.parseDate(date), Date.now(), { addSuffix: true })
0
0
0
GitHub: JacobHsu/ramda
16 17 18 19 20 21 22 23 24 25
const clara = { name: 'clara', age: 40 }; const people = [clara, bob, alice]; const ageNameSort = R.sortWith([ R.descend(R.prop('age')), R.ascend(R.prop('name')) ]); let ageNameSortRes = ageNameSort(people); //=> [alice, clara, bob]
0
0
0
12754 12755 12756 12757 12758 12759 12760 12761 12762 12763
* const clara = { * name: 'clara', * age: 40 * }; * const people = [clara, bob, alice]; * const ageNameSort = R.sortWith([ * R.descend(R.prop('age')), * R.ascend(R.prop('name')) * ]); * ageNameSort(people); //=> [alice, clara, bob]
0
0
2
+ 3 other calls in file
1 2 3 4 5 6 7 8 9 10 11 12
const { promisify } = require('util'); const { splitWhenever, equals, map, sum, addIndex, sortWith, descend, prop, head } = require('ramda'); const read = promisify(readFile); const mapWithIndex = addIndex(map); const sortByCaloriesDesc = sortWith([descend(prop('calories'))]); read('./input') .then(String) .then(data => data.split(/\r?\n/))
0
0
0
GitHub: znevrly/new-report
288 289 290 291 292 293 294 295 296 297 298 299
function parseFeatures(features) { return sort(features.map(getFeatureStatus).map(parseTags).map(processScenarios()).map(sortScenariosForFeature)); } function sort(list) { return R.sortWith([R.ascend(R.prop('line'))], list); } function getFeatureStatus(feature) { feature.status = Summary.getFeatureStatus(feature);
0
0
0
GitHub: DPANET/PrayersHomeySDK3
172 173 174 175 176 177 178 179 180 181
prayerDurationTime: 30, prayerAfterBefore: DurationAfterBefore.Before, prayerDurationType: DurationTypes.Seconds, upcomingPrayerTime: getPrayerTime }); let sortWith = ramda.sortWith([ ramda.descend(ramda.prop('prayerName')), ramda.descend(ramda.prop('prayerAfterBefore')), ramda.descend(ramda.prop('prayerDurationType')), ramda.descend(ramda.prop('prayerDurationTime'))
0
0
0
ramda.clone is the most popular function in ramda (30311 examples)