title: Sorting array keeping even values on top PHP
body: <p>I have tried sorting the below array to keep the even values on top and in sorted order from <code>asc</code> to <code>desc</code> </p>
  
  <pre><code>$array = array(1,2,3,4,5,6,7,8,9,10);
  </code></pre>
  
  <p>I tried this to sort the array </p>
  
  <pre><code>usort($array, function($a, $b) { 
                      if ($a % 2 == 0 )
                      { 
                          return 1 ;
                      }
                      else 
                      { 
                          return -1;
                      }
              }
          );
  </code></pre>
  
  <p>I got the output like below </p>
  
  <pre><code>Array
  (
      [0] =&gt; 7
      [1] =&gt; 9
      [2] =&gt; 1
      [3] =&gt; 5
      [4] =&gt; 3
      [5] =&gt; 2
      [6] =&gt; 4
      [7] =&gt; 6
      [8] =&gt; 8
      [9] =&gt; 10
  )
  </code></pre>
  
  <p>And I want the output array to be </p>
  
  <pre><code>Array
  (
      [0] =&gt; 2
      [1] =&gt; 4
      [2] =&gt; 6
      [3] =&gt; 8
      [4] =&gt; 10
      [5] =&gt; 1
      [6] =&gt; 3
      [7] =&gt; 5
      [8] =&gt; 7
      [9] =&gt; 9
  )
  </code></pre>
  
  <p>The even and odd values should be sorted in asc to desc order but keep the even values on top of odd values</p>