From 6cd84ebe81e25dcdf4e04c1e76b5afed435d4217 Mon Sep 17 00:00:00 2001 From: barisusakli Date: Sun, 7 Sep 2014 13:03:06 -0400 Subject: [PATCH] removed parseInt from sorts --- src/categories/recentreplies.js | 4 ++-- src/socket.io/topics.js | 2 +- src/topics/popular.js | 8 +++----- src/user/notifications.js | 2 +- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/categories/recentreplies.js b/src/categories/recentreplies.js index 2fdd5306bf..97199e636e 100644 --- a/src/categories/recentreplies.js +++ b/src/categories/recentreplies.js @@ -46,9 +46,9 @@ module.exports = function(Categories) { function assignPostsToCategory(category, posts, next) { category.posts = posts.filter(function(post) { - return parseInt(post.category.cid, 10) === parseInt(category.cid); + return parseInt(post.category.cid, 10) === parseInt(category.cid, 10); }).sort(function(a, b) { - return parseInt(b.timestamp, 10) - parseInt(a.timestamp, 10); + return b.timestamp - a.timestamp; }).slice(0, parseInt(category.numRecentReplies, 10)); next(); diff --git a/src/socket.io/topics.js b/src/socket.io/topics.js index 143f5abb5c..699c840bdc 100644 --- a/src/socket.io/topics.js +++ b/src/socket.io/topics.js @@ -550,7 +550,7 @@ SocketTopics.searchAndLoadTags = function(socket, data, callback) { tag.score = results.counts[index]; }); results.tagData.sort(function(a, b) { - return parseInt(b.score, 10) - parseInt(a.score, 10); + return b.score - a.score; }); callback(null, results.tagData); diff --git a/src/topics/popular.js b/src/topics/popular.js index 2dadb9fee6..017153de69 100644 --- a/src/topics/popular.js +++ b/src/topics/popular.js @@ -66,11 +66,9 @@ module.exports = function(Topics) { return callback(err); } - topics.sort(function(a, b) { - return parseInt(b.postcount, 10) - parseInt(a.postcount, 10); - }); - - topics = topics.slice(0, count).map(function(topic) { + topics = topics.sort(function(a, b) { + return b.postcount - a.postcount; + }).slice(0, count).map(function(topic) { return topic.tid; }); diff --git a/src/user/notifications.js b/src/user/notifications.js index e165512178..16feb87d19 100644 --- a/src/user/notifications.js +++ b/src/user/notifications.js @@ -108,7 +108,7 @@ var async = require('async'), } notifs = notifs.filter(Boolean).sort(function(a, b) { - return parseInt(b.datetime, 10) - parseInt(a.datetime, 10); + return b.datetime - a.datetime; }); callback(null, notifs);