title: Sort JSON with PHP based on aggregated nested values
body: <p>I need to:</p>
  <ol>
  <li>Sort the arrays by the <strong>aggregate price</strong> of <strong>each combination</strong>.</li>
  <li>Return only 40% of them with the <strong>highest aggregate price</strong>.</li>
  </ol>
  <pre class="lang-json prettyprint-override"><code>$combinations = '[
      [                          //1st combination
          {&quot;id&quot;:1,&quot;price&quot;:11900},
          {&quot;id&quot;:2,&quot;price&quot;:499},
          {&quot;id&quot;:3,&quot;price&quot;:2099}
      ],
      [                          //2nd combination
          {&quot;id&quot;:1,&quot;price&quot;:11900},
          {&quot;id&quot;:2,&quot;price&quot;:499},
          {&quot;id&quot;:4,&quot;price&quot;:999}
      ],
      [                          //3rd combination
          {&quot;id&quot;:1,&quot;price&quot;:11900},
          {&quot;id&quot;:2,&quot;price&quot;:499},
          {&quot;id&quot;:5,&quot;price&quot;:899}
      ],
      [                          //4th combination
          {&quot;id&quot;:1,&quot;price&quot;:11900},
          {&quot;id&quot;:2,&quot;price&quot;:499},
          {&quot;id&quot;:6,&quot;price&quot;:2999}
      ]
  ]';
  </code></pre>