Node.js based forum software built for the modern web
closes #5708
psychobunnyd70ccb186880
diff --git a/src/topics/popular.js b/src/topics/popular.jsindex e6d78ad4b4..7d756a1548 100644--- a/src/topics/popular.js+++ b/src/topics/popular.js@@ -9,7 +9,13 @@ module.exports = function (Topics) {count = parseInt(count, 10) || 20;if (term === 'alltime') {- return getAllTimePopular(uid, count, callback);+ return getAllTimePopular(uid, count, function (err, topics) {+ if (err) {+ return callback(err);+ }++ sortTiedTopicsByViews(topics, callback);+ });}async.waterfall([@@ -19,6 +25,9 @@ module.exports = function (Topics) {function (tids, next) {getTopics(tids, uid, count, next);},+ function (topics, next) {+ sortTiedTopicsByViews(topics, next);+ },], callback);};@@ -48,4 +57,12 @@ module.exports = function (Topics) {},], callback);}++ function sortTiedTopicsByViews(topics, next) {+ topics.sort(function (a, b) {+ return parseInt(a.postcount) !== parseInt(b.postcount) ? 0 : parseInt(b.viewcount, 10) - parseInt(a.viewcount, 10);+ });++ next(null, topics);+ }};