From 489d5c96d643b38467150a342270c31d3191ab4e Mon Sep 17 00:00:00 2001 From: Mawoka Date: Sun, 25 Sep 2022 21:50:09 +0200 Subject: [PATCH] :sparkles: Endpoint for live player-scores now sorted --- classquiz/routers/quiz.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/classquiz/routers/quiz.py b/classquiz/routers/quiz.py index 1c5c171..eaa81aa 100644 --- a/classquiz/routers/quiz.py +++ b/classquiz/routers/quiz.py @@ -355,5 +355,6 @@ async def get_live_player_scores(game_pin: int): res = await redis.hgetall(f"game_session:{game_pin}:player_scores") return_arr = [] for username in res: - return_arr.append({"useranme": username, "score": res[username]}) + return_arr.append({"username": username, "score": int(res[username])}) + return_arr = sorted(return_arr, key=lambda d: d["score"], reverse=True) return return_arr