From 5f2b66706241b3dfbd32dbdcaabb79a1fca34f07 Mon Sep 17 00:00:00 2001 From: baz Date: Tue, 31 Dec 2024 00:38:50 +0000 Subject: [PATCH] Fix date sorting --- databaseHelperFunctions.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/databaseHelperFunctions.js b/databaseHelperFunctions.js index 1a7dbae..074b764 100644 --- a/databaseHelperFunctions.js +++ b/databaseHelperFunctions.js @@ -310,8 +310,10 @@ async function getLeaderboardEntries() { results.push(result); } - await results.sort((a, b) => parseInt(a.dateLastBeat) - parseInt(b.dateLastBeat)); - await results.sort((a, b) => parseInt(b.count) - parseInt(a.count)); + results.sort((a, b) => new Date(a.dateLastBeat) - new Date(b.dateLastBeat)); + results.sort((a, b) => parseInt(b.count) - parseInt(a.count)); + + console.log(results); return results; } @@ -347,8 +349,8 @@ async function getLeaderboardEntriesBetweenDates(start, end) { results.push(result); } - await results.sort((a, b) => parseInt(a.dateLastBeat) - parseInt(b.dateLastBeat)); - await results.sort((a, b) => parseInt(b.count) - parseInt(a.count)); + results.sort((a, b) => new Date(a.dateLastBeat) - new Date(b.dateLastBeat)); + results.sort((a, b) => parseInt(b.count) - parseInt(a.count)); return results; }