From 5714cc0aef25641ee44a23e5e171ac2e5c28cf25 Mon Sep 17 00:00:00 2001 From: maxchwa <172252921+maxchwa@users.noreply.github.com> Date: Wed, 20 May 2026 09:15:49 +0800 Subject: [PATCH] Max Chwa mc5693: Added sorting function and live score updates. --- static/scoreboard.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/static/scoreboard.js b/static/scoreboard.js index 34ce2009..b65c87ec 100644 --- a/static/scoreboard.js +++ b/static/scoreboard.js @@ -1,5 +1,8 @@ function display_scoreboard(scoreboard){ $("#teams").empty(); + scoreboard.sort(function(a, b){ + return b.score - a.score; + }); $.each(scoreboard, function(index, team){ addTeamView(team.id, team.name, team.score); }); @@ -32,7 +35,7 @@ function increase_score(id){ contentType: "application/json; charset=utf-8", data : JSON.stringify(team_id), success: function(result){ - + display_scoreboard(result.scoreboard); }, error: function(request, status, error){ console.log("Error");