From 10be436761802efaa05043cdee2c9c3d53fb0a85 Mon Sep 17 00:00:00 2001 From: Abhiram Date: Wed, 10 Dec 2025 02:45:47 -0500 Subject: [PATCH] Completed CBL coding challenge --- server.py | 3 +++ static/scoreboard.js | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/server.py b/server.py index 372a266c..cab66a74 100644 --- a/server.py +++ b/server.py @@ -50,6 +50,9 @@ def increase_score(): for team in scoreboard: if team["id"] == team_id: team["score"] += 1 + + # sort teams in non-increasing order of score + scoreboard = sorted(scoreboard, key=lambda x: x["score"], reverse=True) return jsonify(scoreboard=scoreboard) diff --git a/static/scoreboard.js b/static/scoreboard.js index 34ce2009..9ad828d0 100644 --- a/static/scoreboard.js +++ b/static/scoreboard.js @@ -32,7 +32,9 @@ function increase_score(id){ contentType: "application/json; charset=utf-8", data : JSON.stringify(team_id), success: function(result){ - + // this is where we will update the scoreboard + scoreboard = result.scoreboard; + display_scoreboard(scoreboard); }, error: function(request, status, error){ console.log("Error");