title: Underscore: Find the most frequently occurring object in an array?
body: <p>I have here an array of object.</p>
  
  <pre><code>var list = [
      {"id": 439, "name": "John"},
      {"id": 439, "name": "John"},
      {"id": 100, "name": "Kevin"},
      {"id": 120, "name": "Max"},
      {"id": 439, "name": "John"}
  ];
  </code></pre>
  
  <p>I need to extract from this array, the most frequent occurring object and build a new array of it ordered by the most popular name.</p>
  
  <p>So far, I have tried to follow the way it was done from this topic : <a href="https://stackoverflow.com/questions/18878571/underscore-js-find-the-most-frequently-occurring-value-in-an-array">Underscore.js: Find the most frequently occurring value in an array?</a></p>
  
  <pre><code>// Build temp list
  temp_list = _(
      _.chain(
          _(list).pluck('id')
      )
      .countBy()
      .pairs()
      .value()
  )
  .sortBy(1)
  .reverse();
  
  // Build final list with most frequently occurring first
  _.map(temp_list, function(current) {
      return _.findWhere(list, {
          'id': parseInt(current[0])
      });
  });
  </code></pre>
  
  <p>Could exists a way to improve this code by sorting directly initial list without the need to create a temp list ?</p>