Skip to content

Commit

Permalink
Fix sorting for days with cancelled scores
Browse files Browse the repository at this point in the history
  • Loading branch information
logist committed Dec 8, 2020
1 parent fe63d76 commit a4fe2dc
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/calculate.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@ function compareRankingByDay(day) {
function compareTotalRankingByDay(day) {
return function (a, b) {
if (a.total_scores[day] === b.total_scores[day]) {
return +a.id - +b.id;
if (a.completed[day] === b.completed[day]) {
return +a.id - +b.id;
}
if (!a.completed[day]) return 1;
if (!b.completed[day]) return -1;
return a.completed[day] - b.completed[day];
}
return b.total_scores[day] - a.total_scores[day];
};
Expand Down

0 comments on commit a4fe2dc

Please sign in to comment.