From c8523b908ccb5e9f114ea60cee00ca448b90e757 Mon Sep 17 00:00:00 2001 From: Arno Hovhannisyan Date: Tue, 2 Jul 2019 15:30:05 +0400 Subject: [PATCH] #506 --- ui/gist-selection/gist-selection.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/ui/gist-selection/gist-selection.js b/ui/gist-selection/gist-selection.js index b184c832..3515aa83 100644 --- a/ui/gist-selection/gist-selection.js +++ b/ui/gist-selection/gist-selection.js @@ -55,13 +55,15 @@ document const selectionTemplate = ` `; -gists.forEach(gist => { - const html = selectionTemplate - .replace(new RegExp("@description", "g"), gist.description) - .replace(new RegExp("@id", "g"), gist.id) - .replace( - new RegExp("@timestamp", "g"), - timeSince(new Date(gist.updated_at)) - ); - appendHTML(selectionContainer, html); -}); +gists + .sort((a, b) => new Date(b.updated_at) - new Date(a.updated_at)) + .forEach(gist => { + const html = selectionTemplate + .replace(new RegExp("@description", "g"), gist.description) + .replace(new RegExp("@id", "g"), gist.id) + .replace( + new RegExp("@timestamp", "g"), + timeSince(new Date(gist.updated_at)) + ); + appendHTML(selectionContainer, html); + });