Ranking methods: Difference between revisions
→Functional ES5 Dropped assumption of pre-sorted data, and wrapped named expressions in functions
m (→Functional ES5: (formatting)) |
|||
Line 797:
ns = [44, 42, 42, 41, 41, 41, 39],
}).sort(function (a, b) { return
names = sorted.map(function (x) { return x.name; }),
scores = sorted.map(function (x) { return x.score; }),
unique = scores.filter(function (x, i) {
return {▼
name: xs[index],▼
score: score,▼
var standard = function
return scores.indexOf(score) + 1;
Modified: reversed.length - reversed.indexOf(score),▼
modified = function
return reversed.length - reversed.indexOf(score);
},
dense = function (score) {
return unique.indexOf(score) + 1;
},
fractional = function (score) {
return (
(scores.indexOf(score) + 1) +
},
rankings = function (score, index) {
▲ return {
▲ score: score,
Standard: standard(score),
Modified: modified(score),
Dense: dense(score),
Ordinal: index + 1,
Fractional: fractional(score)
▲ Fractional: (
▲ (list.indexOf(score) + 1) +
▲ (reversed.length - reversed.indexOf(score))
▲ ) / 2
};
},
Line 827 ⟶ 846:
tbl = [
'Name Score Standard Modified Dense Ordinal Fractional'.split(' ')
].concat(
return a.concat([[x.name, x.score,
]]);
▲ ]
▲ ]);
}, [])),
|