title: PHP function to reorder an array
body: <p>Here is a sample array of all external JS files from paypal.com:</p>
  
  <pre><code>Array
  (
      [src] =&gt; Array
          (
              [1] =&gt; https://www.paypalobjects.com/WEBSCR-590-20090814-1/js/lib/min/global.js
              [2] =&gt; https://www.paypalobjects.com/WEBSCR-590-20090814-1/js/tns/mid.js
              [8] =&gt; https://www.paypalobjects.com/WEBSCR-590-20090814-1/js/opinionlab/oo_engine.js
              [11] =&gt; https://www.paypalobjects.com/WEBSCR-590-20090814-1/js/iconix.js
              [12] =&gt; https://www.paypalobjects.com/WEBSCR-590-20090814-1/js/pageBlockingUnsafeBrowsers.js
              [13] =&gt; https://www.paypalobjects.com/js/tns/min/bid.js
              [15] =&gt; https://www.paypalobjects.com/WEBSCR-590-20090814-1/js/pp_naturalsearch.js
              [17] =&gt; https://www.paypalobjects.com/WEBSCR-590-20090814-1/js/site_catalyst/pp_jscode_080706.js
          )
  
      [size] =&gt; Array
          (
              [1] =&gt; 0.273
              [2] =&gt; 0.266
              [8] =&gt; 0.279
              [11] =&gt; 0.265
              [12] =&gt; 0.285
              [13] =&gt; 0.248
              [15] =&gt; 0.275
              [17] =&gt; 0.289
          )
  
  )
  </code></pre>
  
  <p>Is there are built in function to PHP, or custom which can reorder this array to this (without being a big performance hit either):</p>
  
  <pre><code>Array
  (
      [src] =&gt; Array
          (
              [1] =&gt; https://www.paypalobjects.com/WEBSCR-590-20090814-1/js/lib/min/global.js
              [2] =&gt; https://www.paypalobjects.com/WEBSCR-590-20090814-1/js/tns/mid.js
              [3] =&gt; https://www.paypalobjects.com/WEBSCR-590-20090814-1/js/opinionlab/oo_engine.js
              [4] =&gt; https://www.paypalobjects.com/WEBSCR-590-20090814-1/js/iconix.js
              [5] =&gt; https://www.paypalobjects.com/WEBSCR-590-20090814-1/js/pageBlockingUnsafeBrowsers.js
              [6] =&gt; https://www.paypalobjects.com/js/tns/min/bid.js
              [7] =&gt; https://www.paypalobjects.com/WEBSCR-590-20090814-1/js/pp_naturalsearch.js
              [8] =&gt; https://www.paypalobjects.com/WEBSCR-590-20090814-1/js/site_catalyst/pp_jscode_080706.js
          )
  
      [size] =&gt; Array
          (
              [1] =&gt; 0.273
              [2] =&gt; 0.266
              [3] =&gt; 0.279
              [4] =&gt; 0.265
              [5] =&gt; 0.285
              [6] =&gt; 0.248
              [7] =&gt; 0.275
              [8] =&gt; 0.289
          )
  
  )
  </code></pre>