If this array:
[ { "name" : "lala", "source_ip" : "10.10.10.10" }, { "name" : "lulu", "source_ip" : "10.10.10.11" }, { "name" : "lolo", "source_ip" : "10.10.10.10" } ]
I would like to group by occurrence and sort it with Lodash to get this result:
[ { "source_ip" : "10.10.10.10", "count" : 2 }, { "source_ip" : "10.10.10.11", "count" : 1 }, ]
Here is what I tried:
app.filter('top10', function() { return function(incidents) { return _.chain(incidents) .countBy("source_ip") .value(); }; });
I also tried reducing to and then using grouBy , but it does not work.
Thank you very much.
Elwyn source share