function normalizeResult(result) { if (result.modules) { result.modules = _.sortByAll(result.modules, ['path']); } if (result.issues) { result.issues = _.sortByAll(result.issues, ['type', 'importingModule', 'exportingModule.resolved', 'line']); } return JSON.parse(JSON.stringify(result)); }
ocd.forEach(function(obj) { var input = obj.word; console.log('working on input', input); if (!input) return [] input = input.toLowerCase() var inputPron = obj.pron; var results = []; for (var i = 0; i < ocd.length; i += 1) { var obj2 = ocd[i]; var score = countMatchingTrailingSyllablesInPronunciations(inputPron, obj2.pron) if (score > 1) { // console.log(results) results.push(merge(obj2, {score: score})) } } var results = sortByAll(results, ['score', 'coolness']); results.reverse(); results = results.map(function(r) { return r.word; }); map[input] = results; });
core.rooms.list(options, function(err, rooms) { if (err) { console.error(err); return res.status(400).json(err); } if (req.param('users')) { rooms = _.map(rooms, function(room) { room = room.toJSON(); room.users = core.presence.getUsersForRoom(room.id.toString()); room.userCount = room.users.length; return room; }); } else if (req.param('userCounts')) { rooms = _.map(rooms, function(room) { room = room.toJSON(); room.userCount = core.presence.getUserCountForRoom(room.id); return room; }); } rooms = _.sortByAll(rooms, ['userCount', 'lastActive']) .reverse(); res.json(rooms); });
}, function(err, response, body) { expect(response.statusCode).to.equal(200); var records = JSON.parse(body).map(function(r) { return _.omit(r, 'id'); }); expect(records).to.eql(_.sortByAll(test.userlist, ['email'])); done(); });
onReceiveTags(tags) { this.tags = _.sortByAll(tags, ['category.position', 'position']); this.tagCategory = _.uniq(_.sortBy(_.map(tags, tag => { return tag.category; }), 'position'), 'id'); this.emitChange(); }
function sortItem(item, key) { if (_.has(item, 'properties')) { item = cleanItem(item, key); //item = sanitizeItem(item); } else if (item.rights && item.rights.itemRight) { if (item.rights.itemRight instanceof Array) { item.rights.itemRight = _.sortBy(item.rights.itemRight, '$name'); } if (item.rights.propertyRight instanceof Array) { item.rights.propertyRight = _.sortBy(item.rights.propertyRight, '$name'); } } if (item.tags && item.tags.tag && item.tags.tag instanceof Array) { item.tags.tag = _.sortByAll(item.tags.tag, ['_', '$type', '$blacklist']); } return item; }
find.exec(function(err, rooms) { if (err) { return cb(err); } _.each(rooms, function(room) { this.sanitizeRoom(options, room); }, this); if (options.users && !options.sort) { rooms = _.sortByAll(rooms, ['userCount', 'lastActive']) .reverse(); } cb(null, rooms); }.bind(this));
rl.on('close', function () { var table = new Table({ head: ['Name', 'Quantity'] }); uaArr.forEach(function (value, index) { if (value.browser.name) { table.push([ value.browser.name + ' ' + value.browser.major, value.count ]); } else { table.push([ 'Not recognized', value.count ]); } }); _.sortByAll(uaArr, ['name']); console.log(table.toString()); });
.spread(function (a, ab) { expect(a).to.eql(aOld); expect(ab).to.eql(_.sortByAll(abOld.concat([{ aid1: 1, aid2: '2', bid3: 1, bid4: '2' }]), ['bid3', 'bid4', 'aid1', 'aid2'])); });
onNewRoundData: function(chartData, opts) { // new round data means the round selection needs to be cleared out //this.state.selectedRound = null; // Sort series chartData.stakes = _.sortByAll( // Start by reversing the stakes so last person in becomes first chartData.stakes.reverse(), // Now sorts: // First, all Option Pools go to the end (latest option pools go last) function(s) { return s.stake.isOptionsPool ? 1 + s.stake.round.sequenceI : 0; }, // Then common behind preferred function(s) { return s.stake.shareClass === ShareClass.COMMON ? 1 : 0; }, // Then liquidation seniority function(s) { return -1 * s.stake.liquidationSeniority || 0; } // Stable sort preserves remaining by round ); // Calculate the stack data (modifies the underlying lists) PERCENTAGE_STACK_CALC(chartData.stakes); // adds stacking calcs to .percentages VALUE_STACK_CALC(chartData.stakes); // adds stacking calcs to .values // consumer can do either // _.pluck(chartData.stakes, 'percentages') // _.pluck(chartData.stakes, 'values') // to render window.heydanData = chartData; colorStakes(chartData); var roundChartConfig = { xAxis: { domain: _.pluck(chartData.rounds, 'round.id'), range: _.pluck(chartData.rounds, 'round.name') }, datasets: { 'percentages': processStakesIntoMeasureDataset(chartData, 'percentages'), 'values': processStakesIntoMeasureDataset(chartData, 'values'), }, showFirstRoundLabels: this.state.showFirstRoundLabels }; // Now do the scatter transforms var percentValueConfig = { series: chartData.stakes.map(function(stakeWrap) { return { color: stakeWrap.color, stake: stakeWrap.stake, data: stakeWrap.percentages .map(function(p, i) { return { // percentage axis: percentage: p.n, // value axis: value: stakeWrap.values[i].n, // meta: round: p.xRound, roundStats: p.xRoundStats, exitStats: p.exitStats || null }; }) // filter out any null points (side-effect of stacked bar chart normalization) .filter(tuple => tuple.percentage !== null) }; }) }; var allDataPoints = _(percentValueConfig.series).pluck('data').flatten().value(); percentValueConfig.axes = { value: { formatter: CURRENCY_FORMATTER, domain: [ 0, Math.floor( _(allDataPoints).pluck('value').max() ) // floor to get rid of .00000001 floating point glitches ] }, percentage: { formatter: PERCENTAGE_FORMATTER, domain: [ 0, Math.min( _(allDataPoints).pluck('percentage').max(), 1 ) // make sure never past 100%, eg 1.00000002 ] } }; // Axis Lock. Keep the axes the max seen since the last time the axis lock was enabled. var axisLimits = this.state.percentValueConfigAxisLimits; // convenience alias axisLimits.value[0] = Math.min(axisLimits.value[0], percentValueConfig.axes.value.domain[0]); axisLimits.value[1] = Math.max(axisLimits.value[1], percentValueConfig.axes.value.domain[1]); axisLimits.percentage[0] = Math.min(axisLimits.percentage[0], percentValueConfig.axes.percentage.domain[0]); axisLimits.percentage[1] = Math.max(axisLimits.percentage[1], percentValueConfig.axes.percentage.domain[1]); axisLimits.lastValueDomain = percentValueConfig.axes.value.domain; axisLimits.lastPercentageDomain = percentValueConfig.axes.percentage.domain; if (this.state.percentValueConfigAxisLimits.axisLock) { percentValueConfig.axes.value.domain = axisLimits.value; percentValueConfig.axes.percentage.domain = axisLimits.percentage; } window.hdRoundChartConfig = roundChartConfig; this.state.roundChartConfig = roundChartConfig; window.hdPercentValueConfig = percentValueConfig; this.state.percentValueConfig = percentValueConfig; this.emitState(opts); },
filterRates() { this.applicableRates = []; this.applicableRates = this.rates.filter(this.rateMatchesCriteria.bind(this)); sortByAll(this.applicableRates, ['rateClassCode', 'rateTypeCode', 'activityTypeCode', 'fiscalYear', 'onOffCampusFlag'], [true, true, true, true, false]); this.makeRateMap(); }
module.exports = function multiSort(by){ return _.sortByAll(courses, _.map(by, getSortingOption)); }