title: PHP: How to move array item to the first place without changing its key if value is numeric?
body: <p>Here is my array:</p>
  
  <pre><code>$arrayA = array(0 =&gt; "someString",
                  1 =&gt; "otherString",
                  2 =&gt; "2017",
                  3 =&gt; "anotherString",
                  4 =&gt; "2016"); 
  </code></pre>
  
  <p>My goal is to to find the first item that has a numeric value (which would be "2017") and place it first in the array, without changing its original key and keeping the others in the same order. </p>
  
  <p>So I want:</p>
  
  <pre><code>$arrayA = array(2 =&gt; "2017",
                  0 =&gt; "someString",
                  1 =&gt; "otherString",
                  3 =&gt; "anotherString",
                  4 =&gt; "2016"); 
  </code></pre>
  
  <p>I tried <code>uasort()</code> php function and it seems the way to do it, but I could not figure out how to build the comparison function to go with it. </p>
  
  <p>PHP documentation shows an example:</p>
  
  <pre><code>function cmp($a, $b) {
      if ($a == $b) {
          return 0;
      }
      return ($a &lt; $b) ? -1 : 1;
  }
  </code></pre>
  
  <p>But, WHO is <code>$a</code> and WHO is <code>$b</code>?</p>
  
  <p>Well, I tried</p>
  
  <pre><code>    function my_sort($a,$b) {
          if ($a == $b ) {
              return 0;
          } 
          if (is_numeric($a) &amp;&amp; !is_numeric($b)) {
              return -1;
              break;
          }
      }
  </code></pre>
  
  <p>But, of course, I am very far from my goal. Any help would be much appreciated.</p>