title: PHP - Sort multi-dimensional array by another array
body: <p>I'm trying to sort a multi-dimensional array by another array, but have so far come up short.<br>
  <a href="http://php.net/manual/en/function.array-multisort.php"><code>array_multisort</code></a> seems be working only for real sorting.</p>
  
  <p>Suppose I have these 2 arrays:</p>
  
  <pre><code>$order = array(2,3,1);
  
  $data = array(
      array('id' =&gt; 1, 'title' =&gt; 'whatever'),
      array('id' =&gt; 2, 'title' =&gt; 'whatever'),
      array('id' =&gt; 3, 'title' =&gt; 'whatever')
  );
  </code></pre>
  
  <p>Now I would like to sort my <code>$data</code> array according to the order in my <code>$order</code> array.<br>
  This is what I would like the result to be:</p>
  
  <pre><code>$data = array(
      array('id' =&gt; 2, 'title' =&gt; 'whatever'),
      array('id' =&gt; 3, 'title' =&gt; 'whatever')
      array('id' =&gt; 1, 'title' =&gt; 'whatever'),
  );
  </code></pre>
  
  <hr>
  
  <p>I can accomplish this easily by running a nested loop, but that would not scale well (my array is pretty big, and the arrays have many more fields).</p>