Skip to content

Commit

Permalink
Update updateLeaderboard.js
Browse files Browse the repository at this point in the history
  • Loading branch information
ChunhThanhDe authored Oct 29, 2024
1 parent e5ba4c4 commit 8304121
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion .github/updateLeaderboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ module.exports = async ({ github, context }) => {

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

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

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

Expand Down

0 comments on commit 8304121

Please sign in to comment.