From bfe28f2f44028360bc2ae5002495d048203937c5 Mon Sep 17 00:00:00 2001 From: Sai Dinesh C Date: Sun, 25 Jan 2026 20:06:33 -0500 Subject: [PATCH 1/2] CBL Coding Exercise - Sai Dinesh Chintaginajala - sc5811 --- server.py | 1 + static/scoreboard.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/server.py b/server.py index 372a266c..f7b32153 100644 --- a/server.py +++ b/server.py @@ -51,6 +51,7 @@ def increase_score(): if team["id"] == team_id: team["score"] += 1 + scoreboard.sort(key=lambda x: x['score'], reverse=True) return jsonify(scoreboard=scoreboard) diff --git a/static/scoreboard.js b/static/scoreboard.js index 34ce2009..46fd669a 100644 --- a/static/scoreboard.js +++ b/static/scoreboard.js @@ -32,7 +32,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"); From 73f2c0dc16d8e83004cd72c3b8eab93da007d877 Mon Sep 17 00:00:00 2001 From: Sai Dinesh C Date: Sun, 25 Jan 2026 20:17:40 -0500 Subject: [PATCH 2/2] added comments --- server.py | 1 + static/scoreboard.js | 1 + 2 files changed, 2 insertions(+) diff --git a/server.py b/server.py index f7b32153..48714906 100644 --- a/server.py +++ b/server.py @@ -51,6 +51,7 @@ def increase_score(): if team["id"] == team_id: team["score"] += 1 + # Sort the scoreboard in descending order of score scoreboard.sort(key=lambda x: x['score'], reverse=True) return jsonify(scoreboard=scoreboard) diff --git a/static/scoreboard.js b/static/scoreboard.js index 46fd669a..db4b5fef 100644 --- a/static/scoreboard.js +++ b/static/scoreboard.js @@ -32,6 +32,7 @@ function increase_score(id){ contentType: "application/json; charset=utf-8", data : JSON.stringify(team_id), success: function(result){ + // Update the scoreboard with the new sorted list returned from the server display_scoreboard(result.scoreboard); }, error: function(request, status, error){