Skip to content

Commit 8304121

Browse files
authored
Update updateLeaderboard.js
1 parent e5ba4c4 commit 8304121

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

.github/updateLeaderboard.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,11 @@ module.exports = async ({ github, context }) => {
6666

6767
const leaderboardRows = leaderboardContent.split('\n').filter(row => row.startsWith('|') && !row.includes('Score | Player | Message | Date'));
6868

69-
leaderboardRows.sort((a, b) => parseInt(b.match(/^\| (\d+) \|/)[1]) - parseInt(a.match(/^\| (\d+) \|/)[1]));
69+
leaderboardRows.sort((a, b) => {
70+
const scoreA = a.match(/^\| (\d+) \|/);
71+
const scoreB = b.match(/^\| (\d+) \|/);
72+
return (scoreB ? parseInt(scoreB[1]) : 0) - (scoreA ? parseInt(scoreA[1]) : 0);
73+
});
7074

7175
if (leaderboardRows.length > 20) leaderboardRows.pop();
7276

0 commit comments

Comments
 (0)