Ranking methods: Difference between revisions

Line 797:
 
<lang JavaScript>(function () {
 
var xs = 'Solomon Jason Errol Garry Bernard Barry Stephen'.split(' '),
ns = [44, 42, 42, 41, 41, 41, 39],
 
sorted = xs.map(function (x, i) {
return { name: x, score: ns[i] };
Line 807:
return c ? c : a.name < b.name ? -1 : a.name > b.name ? 1 : 0;
}),
 
names = sorted.map(function (x) { return x.name; }),
scores = sorted.map(function (x) { return x.score; }),
 
reversed = scores.slice(0).reverse(),
unique = scores.filter(function (x, i) {
return scores.indexOf(x) === i;
});
 
 
// RANKINGS AS FUNCTIONS OF SCORES: SORTED, REVERSED AND UNIQUE
var standardrankings = function (score, index) {
)return / 2;{
Ordinalname: names[index + 1],
Densescore: dense(score),
 
ModifiedOrdinal: modified(score)index + 1,
var standard = function (score) {
return scores.indexOf(score) + 1;
},
 
modified = Standard: function (scoren) {
return reversed.length - reversed return scores.indexOf(scoren) + 1;
}(score),
 
dense = Modified: function (scoren) {
return uniquereversed.length - reversed.indexOf(scoren) + 1;
}(score),
 
fractional = Dense: function (scoren) {
return unique.indexOf(n) + 1;
(scores.indexOf}(score) + 1) +,
(reversed.length - reversed.indexOf(score))
) / 2;
},
 
rankings = Fractional: function (score, indexn) {
return {(
name: names[index], (scores.indexOf(n) + 1) +
score: score, (reversed.length - reversed.indexOf(n))
) / 2;
 
Standard: standard}(score),
Modified: modified(score),
Dense: dense(score),
Ordinal: index + 1,
Fractional: fractional(score)
};
},
 
tbl = [
'Name Score Standard Modified Dense Ordinal Fractional'.split(' ')
Line 860 ⟶ 855:
]);
}, [])),
 
//[[a]] -> bool -> s -> s
wikiTable = function (lstRows, blnHeaderRow, strStyle) {
Line 867 ⟶ 862:
) + lstRows.map(function (lstRow, iRow) {
var strDelim = ((blnHeaderRow && !iRow) ? '!' : '|');
 
return '\n|-\n' + strDelim + ' ' + lstRow.map(function (v) {
return typeof v === 'undefined' ? ' ' : v;
Line 873 ⟶ 868:
}).join('') + '\n|}';
};
 
return wikiTable(tbl, true, 'text-align:center');
 
})();</lang>
 
9,659

edits