title: Sorting a Multidimensional Array in PHP
body: <p>My array looks like this:</p>
  
  <pre><code>Array
  (
  [0] =&gt; Array
      (
          [0] =&gt; 1
          [1] =&gt; 6
          [2] =&gt; 4
          [3] =&gt; 5
      )
  
  [1] =&gt; Array
      (
          [0] =&gt; 272.05
          [1] =&gt; 63.54
          [2] =&gt; 544.79
          [3] =&gt; 190.62
      )
  
  [2] =&gt; Array
      (
          [0] =&gt; 2011-03-06 14:08:19
          [1] =&gt; 2011-03-06 14:29:04
          [2] =&gt; 2011-03-06 14:28:39
          [3] =&gt; 2011-03-06 14:29:28
      )
  
  )
  </code></pre>
  
  <p>I want to sort by $myArray[1]. I have this usort function:</p>
  
  <pre><code>function sortAmount($a, $b) { 
      return strnatcmp($a[1], $b[1]); 
  }
  </code></pre>
  
  <p>It is called like this:</p>
  
  <pre><code>usort($myArray, "sortAmount"); 
  </code></pre>
  
  <p>However, the array does not change after calling usort. I want the numbers in $myArray[1] to be sorted in ascending order, and for the corresponding indexes in $myArray[0] and $myArray[2] to change with it.</p>