title: array_multisort with maintaining numeric index association
body: <p>I can sort a multidimensional array but without keeping the numerical index association.</p>
  
  <p><strong>How can I keep the numerical index association?</strong></p>
  
  <p><strong>CODE:</strong></p>
  
  <pre><code>$waiters[76] = array('weight' =&gt; 67, 'specialties' =&gt; 1);
  $waiters[14] = array('weight' =&gt; 41, 'specialties' =&gt; 2);
  $waiters[58] = array('weight' =&gt; 85, 'specialties' =&gt; 3);
  $waiters[89] = array('weight' =&gt; 98, 'specialties' =&gt; 4);
  $waiters[68] = array('weight' =&gt; 86, 'specialties' =&gt; 5);
  $waiters[31] = array('weight' =&gt; 13, 'specialties' =&gt; 6);
  print_r($waiters);
  // Obtain a list of waiters
  foreach ($waiters as $id =&gt; $waiter) {
      $weight[$id]        = $waiter['weight'];
      $specialties[$id]   = $waiter['specialties'];
  
  }
  
  // Sort the data with weight descending, specialties ascending
  // Add $data as the last parameter, to sort by the common key
  array_multisort(
      $weight, SORT_DESC, SORT_NUMERIC, 
      $specialties, SORT_ASC, SORT_NUMERIC, 
      $waiters
  );
  print_r($waiters);
  </code></pre>
  
  <p><strong>OUTPUT:</strong></p>
  
  <pre><code>Array
  (
      [0] =&gt; Array
          (
              [weight] =&gt; 98
              [specialties] =&gt; 4
          )
  
      [1] =&gt; Array
          (
              [weight] =&gt; 86
              [specialties] =&gt; 5
          )
  
      [2] =&gt; Array
          (
              [weight] =&gt; 85
              [specialties] =&gt; 3
          )
  
      [3] =&gt; Array
          (
              [weight] =&gt; 67
              [specialties] =&gt; 1
          )
  
      [4] =&gt; Array
          (
              [weight] =&gt; 41
              [specialties] =&gt; 2
          )
  
      [5] =&gt; Array
          (
              [weight] =&gt; 13
              [specialties] =&gt; 6
          )
  
  )
  </code></pre>
  
  <p><strong>DESIRED OUTPUT:</strong></p>
  
  <pre><code>Array
  (
      [89] =&gt; Array
          (
              [weight] =&gt; 98
              [specialties] =&gt; 4
          )
  
      [68] =&gt; Array
          (
              [weight] =&gt; 86
              [specialties] =&gt; 5
          )
  
      [58] =&gt; Array
          (
              [weight] =&gt; 85
              [specialties] =&gt; 3
          )
  
      [76] =&gt; Array
          (
              [weight] =&gt; 67
              [specialties] =&gt; 1
          )
  
      [14] =&gt; Array
          (
              [weight] =&gt; 41
              [specialties] =&gt; 2
          )
  
      [31] =&gt; Array
          (
              [weight] =&gt; 13
              [specialties] =&gt; 6
          )
  
  )
  </code></pre>