title: Order by nested object property inside a array
body: <p>I'm stuck on this one thing trying to take top 3 manufacturers by numberOfCars, and, to do the same with <code>cars: []</code>, take top 3 by numberoOfCars</p>
  
  <pre><code>audi: {
    cars: [], 
    collectionName: '',
    numberOfCars: 0
  }
  </code></pre>
  
  <p>I can do the first level with lodash like </p>
  
  <p><code>_.take(_.orderBy(modelData, 'numberoOfCars', 'desc'), 3)</code></p>
  
  <p>but I'm lost on doing the same on cars array as mentioned.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>const mock = []
  
  for (let i = 0; i &lt; 140; i++) {
    let manufacturerName
    let name
  
    if (i &lt; 20) {
      manufacturerName = 'Audi'
      name = 'A6'
    } else if (i &gt; 19 &amp;&amp; i &lt; 40) {
      manufacturerName = 'BMW'
      name = '420 GC'
    } else if (i &gt; 19 &amp;&amp; i &lt; 40) {
      manufacturerName = 'Mercedes'
      name = 'AMG'
    } else if (i &gt; 39 &amp;&amp; i &lt; 60) {
      manufacturerName = 'Mazda'
      name = '6'
    } else if (i &gt; 59 &amp;&amp; i &lt; 80) {
      manufacturerName = 'Volvo'
      name = 'V90'
    } else if (i &gt; 79 &amp;&amp; i &lt; 100) {
      manufacturerName = 'Renault'
      name = 'Model'
    } else if (i &gt; 99 &amp;&amp; i &lt; 120) {
      manufacturerName = 'Lamborghini'
      name = 'Aventador'
    } else if (i &gt; 119 &amp;&amp; i &lt; 140) {
      manufacturerName = 'Volkswagen'
      name = 'Golf'
    }
  
    mock.push({
      id: i,
      name: name,
      displayName: 'display-name ' + Math.floor(Math.random() * 10),
      manufacturer: manufacturerName,
      numberoOfCars: Math.floor(Math.random() * 100000),
    })
  }
  
  const dataModel = mock.reduce((accumulator, currentValue) =&gt; {
    const key = currentValue.manufacturer
  
    if (accumulator[key] === undefined) {
      accumulator[key] = {
        collectionName: '',
        numberoOfCars: 0,
        cars: []
      }
    }
  
    if (accumulator[key].collectionName === '') {
      accumulator[key].collectionName = currentValue.manufacturer
    }
  
    if (currentValue.numberoOfCars !== undefined) {
      accumulator[key].numberoOfCars += currentValue.numberoOfCars
    }
  
    if (currentValue.numberoOfCars !== undefined) {
      accumulator[key].cars.push({
        name: currentValue.name,
        numberOfCars: currentValue.numberoOfCars
      })
    }
  
    return accumulator
  }, {})
  
  console.log(dataModel)</code></pre>
  </div>
  </div>
  </p>