From b939d40348149a91525a9543374660c5bdc8ca6d Mon Sep 17 00:00:00 2001 From: Simacbooki Date: Fri, 12 Dec 2025 15:13:04 -0500 Subject: [PATCH] Update scoreboard dynamically and sort by score --- static/scoreboard.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/static/scoreboard.js b/static/scoreboard.js index 34ce2009..5f19529b 100644 --- a/static/scoreboard.js +++ b/static/scoreboard.js @@ -32,7 +32,12 @@ function increase_score(id){ contentType: "application/json; charset=utf-8", data : JSON.stringify(team_id), success: function(result){ - + // sort scoreboard by score descending + result.scoreboard.sort(function(a, b){ + return b.score - a.score; + }); + // update frontend immediately + display_scoreboard(result.scoreboard); }, error: function(request, status, error){ console.log("Error");