Sort logs in descending order

master
Miikka Virtanen 2017-05-18 05:52:21 +03:00
parent e258bf8432
commit 6b26c1cb5c
1 changed files with 3 additions and 2 deletions

View File

@ -124,9 +124,10 @@ function getLogsWithUrlByUserId(userId) {
}); });
return Promise.all(urlPromises).then(infos => { return Promise.all(urlPromises).then(infos => {
// Sort logs by date, in descending order
infos.sort((a, b) => { 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; return 0;
}); });