From 329e79242966ca2a7be346c609096c2337125ef9 Mon Sep 17 00:00:00 2001 From: AryanVBW Date: Fri, 29 Nov 2024 19:55:52 +0530 Subject: [PATCH] Sort users by question count in descending order --- index.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/index.js b/index.js index d53d0f7..4537862 100644 --- a/index.js +++ b/index.js @@ -74,6 +74,9 @@ app.get("/", async (req, res) => { }; }); + // Sort users by questionSolved in descending order + usersData.sort((a, b) => b.questionSolved - a.questionSolved); + res.render("index", { data: usersData }); } catch (error) { console.error("Error fetching data:", error);