Group an array by occurrences and sort it with Lodash
<p>If have this array :</p>

<pre><code>[
  {
    "name" : "lala",
    "source_ip" : "10.10.10.10"
  },
  {
    "name" : "lulu",
    "source_ip" : "10.10.10.11"
  },
  {
    "name" : "lolo",
    "source_ip" : "10.10.10.10"
  }
]
</code></pre>

<p>I would like to group by occurrences and sort it with Lodash to get this result :</p>

<pre><code>[
  {
    "source_ip" : "10.10.10.10",
    "count" : 2
  },
  {
    "source_ip" : "10.10.10.11",
    "count" : 1
  },
]
</code></pre>

<p>Here is what I tried:</p>

<pre><code>app.filter('top10', function() {
  return function(incidents) { 
    return _.chain(incidents)
        .countBy("source_ip")
        .value();
  };
});
</code></pre>

<p>I also tried to reduce before and then use <strong>grouBy</strong> instead but it is not working.</p>

<p>Thanks a lot.</p>