From 6b26c1cb5c4b9e99096f4a7eb66bab77a73dac14 Mon Sep 17 00:00:00 2001 From: Miikka Virtanen Date: Thu, 18 May 2017 05:52:21 +0300 Subject: [PATCH] Sort logs in descending order --- src/logs.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/logs.js b/src/logs.js index 1d14a4b..c72c9e1 100644 --- a/src/logs.js +++ b/src/logs.js @@ -124,9 +124,10 @@ function getLogsWithUrlByUserId(userId) { }); return Promise.all(urlPromises).then(infos => { + // Sort logs by date, in descending order infos.sort((a, b) => { - if (a.date > b.date) return 1; - if (a.date < b.date) return -1; + if (a.date > b.date) return -1; + if (a.date < b.date) return 1; return 0; });