Javascript Array frequencies()
Array.prototype.frequencies = function () { var freqs = {} this.map(function (a) { if (!(a in this)) { this[a] = 1;/*from w ww . j a v a 2 s . c o m*/ } else { this[a] += 1; } return a; }, freqs); return (_.sortBy(_.pairs(freqs), function(num){return num[1]} )).reverse() }