From 05733406d94da3af27c3a1ecbe40b79a421b3045 Mon Sep 17 00:00:00 2001 From: Name Date: Mon, 2 Aug 2021 17:26:08 -0400 Subject: [PATCH] jw4204 Jingyi Wang --- server.py | 3 +++ static/scoreboard.js | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/server.py b/server.py index 372a266c..1f8a7228 100644 --- a/server.py +++ b/server.py @@ -51,6 +51,9 @@ def increase_score(): if team["id"] == team_id: team["score"] += 1 + #sort the scoreboard base on each obj's score + scoreboard.sort(key = lambda obj: obj['score'], reverse = True); + return jsonify(scoreboard=scoreboard) diff --git a/static/scoreboard.js b/static/scoreboard.js index 34ce2009..f48d7c1c 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");