From a992e65b6e94c254836655e2fa2c6a0cb4a82587 Mon Sep 17 00:00:00 2001 From: Luke Slater Date: Sun, 24 Jun 2012 23:58:22 +0100 Subject: [PATCH] make an object sort function in snippets --- modules/kick.js | 11 ++--------- modules/quotes.js | 10 +--------- snippets.js | 12 +++++++++++- 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/modules/kick.js b/modules/kick.js index ff1e42d..a99041b 100644 --- a/modules/kick.js +++ b/modules/kick.js @@ -26,17 +26,10 @@ var kick = function(dbot) { // who have kicked other people the most. '~kickstats': function(event) { var orderedKickLeague = function(list, topWhat) { - var kickArr = []; - for(var kickUser in list) { - if(list.hasOwnProperty(kickUser)) { - kickArr.push([kickUser, list[kickUser]]); - } - } - - kickArr = kickArr.sort(function(a, b) { return a[1] - b[1]; }); + var kickArr = Object.prototype.sort(list, function(key, obj) { return obj[key]; }); kickArr = kickArr.slice(kickArr.length - 10).reverse(); - var kickString = "Top " + topWhat + ": "; + var kickString = "Top " + topWhat + ": "; for(var i=0;i