From 835b8c582123f641da949732f97b458032d73af4 Mon Sep 17 00:00:00 2001 From: = Date: Wed, 7 Feb 2024 20:18:54 +0100 Subject: [PATCH] returned scores are now sorted --- main.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index bcdf40d..1a81349 100644 --- a/main.py +++ b/main.py @@ -25,8 +25,9 @@ def root(): @app.route('/score', methods = ['GET']) @cross_origin() def get_score() -> str: - scoreDTOs = map(lambda score: ScoreDTO(score.score, score.username), scores) - return json.dumps(list(scoreDTOs)) + scoreDTOs: list[ScoreDTO] = list(map(lambda score: ScoreDTO(score.score, score.username), scores)) + scoreDTOs.sort(reverse = True, key = lambda score: score.score) + return json.dumps(scoreDTOs) @app.route('/score', methods = ['POST']) @cross_origin() @@ -72,4 +73,4 @@ def main(): app.run(debug = True) if __name__ == "__main__": - main() \ No newline at end of file + main()