faster sort users

v1.18.x
barisusakli 10 years ago
parent 0fab6c243c
commit f9fecf4bc1

@ -178,18 +178,20 @@ module.exports = function(User) {
} }
function sortUsers(userData, sortBy) { function sortUsers(userData, sortBy) {
userData.sort(function(user1, user2) { if (sortBy === 'joindate' || sortBy === 'postcount') {
if (sortBy === 'joindate' || sortBy === 'postcount') { userData.sort(function(u1, u2) {
return user2[sortBy] - user1[sortBy]; return u2[sortBy] - u1[sortBy];
} else { });
if(user1[sortBy] < user2[sortBy]) { } else {
userData.sort(function(u1, u2) {
if(u1[sortBy] < u2[sortBy]) {
return -1; return -1;
} else if(user1[sortBy] > user2[sortBy]) { } else if(u1[sortBy] > u2[sortBy]) {
return 1; return 1;
} }
return 0; return 0;
} });
}); }
} }
function searchByIP(ip, callback) { function searchByIP(ip, callback) {

Loading…
Cancel
Save