title: Sort multidimensional array on column values DESC, then by length of another column DESC
body: <p>I need to sort some data that is not coming from a database, but is structured like a sql result set.</p>
  <p>In MySQL, I would write a query as follows to sort the data by two columns:</p>
  <pre><code>SELECT product, qty FROM stock ORDER BY qty DESC, LENGTH(product) DESC 
  </code></pre>
  <p>However, in this case, I need to perform this sorting logic with php.  Specifically, the rows are sorted first by descending <code>qty</code>, and then by the length of <code>name</code> descending.</p>
  <p>Unsorted Input:</p>
  <pre><code>[
      ['name' =&gt; 'foo bar', 'qty' =&gt; 6],
      ['name' =&gt; 'foo bar bar foo', 'qty' =&gt; 10],
      ['name' =&gt; 'b', 'qty' =&gt; 5],
      ['name' =&gt; 'foo', 'qty' =&gt; 10],
      ['name' =&gt; 'bar', 'qty' =&gt; 6],
      ['name' =&gt; 'foo bar bar bar foo', 'qty' =&gt; 6],
  ]
  </code></pre>
  <p>After sorting, I need to restructure the data with the <code>name</code> values as keys and the <code>qty</code> values as values of a flat, associative array
  The finished array would look something like this:</p>
  <p>Desired Output:</p>
  <pre><code>[
      'foo bar bar foo' =&gt; 10,
      'foo' =&gt; 10,
      'foo bar bar bar foo' =&gt; 6,
      'foo bar' =&gt; 6,
      'bar' =&gt; 6,
      'b' =&gt; 5
  ]
  </code></pre>