title: Sort array based on user-defined order of index
body: <p>I would like to restructure the array (not traditional sort), based on providing the wanted index order, e.g. [1,7,4].
  Below just sorts ascending order based on value.</p>
  
  <p><strong>wanted result:</strong></p>
  
  <pre><code>Array
  (
      [1] =&gt; c
      [4] =&gt; b
      [7] =&gt; a
  )
  </code></pre>
  
  <hr>
  
  <p><strong>My code:</strong>
      
  
  <pre><code>$array = [];
  
  $array[4] = "b";
  $array[1] = "c";
  $array[7] = "a";
  
  print_r($array);
  
  echo "\n\n" . "Sort ascending..." . "\n\n";
  asort($array);
  print_r($array);
  </code></pre>
  
  <p><strong>Result:</strong></p>
  
  <pre><code>Array
  (
      [4] =&gt; b
      [1] =&gt; c
      [7] =&gt; a
  )
  
  
  Sort ascending...
  
  Array
  (
      [7] =&gt; a
      [4] =&gt; b
      [1] =&gt; c
  )
  </code></pre>