Ranking methods: Difference between revisions
m
→Functional ES5
m (→Functional ES5) |
|||
Line 801:
ns = [44, 42, 42, 41, 41, 41, 39],
sorted = xs.map(function (
return { name:
}).sort(function (a, b) {
var
return c ? c : a.name < b.name ? -1 : a.name > b.name ? 1 : 0;▼
return d ? d : ( ▼
▲ a.name > b.name ? 1 : 0
}),
names = sorted.map(function (x) { return x.name; }),
scores = sorted.map(function (x) { return x.score; }),
Line 823 ⟶ 818:
// RANKINGS AS FUNCTIONS OF SCORES: SORTED, REVERSED AND UNIQUE
var standard = function (score) {
return scores.indexOf(score) + 1;
},
modified = function (score) {
return reversed.length - reversed.indexOf(score);
},
dense = function (score) {
return unique.indexOf(score) + 1;
},
fractional = function (score) {
return (
Line 847 ⟶ 842:
name: names[index],
score: score,
Standard: standard(score),
Modified: modified(score),
Line 859 ⟶ 854:
'Name Score Standard Modified Dense Ordinal Fractional'.split(' ')
].concat(scores.map(rankings).reduce(function (a, x) {
return a.concat([
[x.
x.Standard, x.Modified, x.Dense, x.Ordinal, x.Fractional
▲ ]);
}, [])),
|