diff --git a/lib/logs.js b/lib/logs.js index dbea09e..5f1b48a 100644 --- a/lib/logs.js +++ b/lib/logs.js @@ -97,13 +97,15 @@ Logs.prototype.logFiles = function (callback) { async.filter(files, function (file, cb) { fs.stat(file.path, function (err, stat) { + file.created = stat.birthtime.toISOString() + file.modified = stat.mtime.toISOString() file.formattedSize = filesize(stat.size) file.size = stat.size cb(!err && stat.isFile()) }) }, function (files) { files.sort(function (a, b) { - return a.name.toLowerCase().localeCompare(b.name.toLowerCase()) + return b.created.localeCompare(a.created) // Descending order }) callback(null, files) diff --git a/public/js/app/collections/logs.js b/public/js/app/collections/logs.js index c63a56e..a5b5170 100644 --- a/public/js/app/collections/logs.js +++ b/public/js/app/collections/logs.js @@ -3,7 +3,9 @@ var Backbone = require('backbone') var Log = require('app/models/log') module.exports = Backbone.Collection.extend({ - comparator: 'name', + comparator: function (a, b) { + return b.get('created').localeCompare(a.get('created')) // Descending order + }, model: Log, url: '/api/logs/' })