title: PHP: array int compare error?
body: <p>I don't know why I cannot get the expected result.
  The result shows 2 > 10 > 1 but I want 10 > 2 > 1
  Can anyone help me? Thanks</p>
  
  <pre><code>&lt;?
  function reorder($a, $b)
      {
          $a = substr($a, strlen("a/"));
          $a = substr($a, 0, -strlen(".php"));
          $b = substr($b, strlen("a/"));
          $b = substr($b, 0, -strlen(".php"));
          switch ($a) {
              case "1m_microUSB_cable":
                  $a['order'] = 1;
                  break;
              case "25cm_microUSB_cable":
                  $a['order'] = 2;
                  break;
              case "30cm_lightning_cable":
                  $a['order'] = 3;
                  break;
              case "1.5m_lightning_cable":
                  $a['order'] = 5;
                  break;
              case "1m_lightning_cable":
                  $a['order'] = 4;
                  break;
              case "1m_microUSB_upgrade_cable":
                  $a['order'] = 6;
                  break;
              case "hand_ring_cable_Android":
                  $a['order'] = 7;
                  break;
              case "hand_ring_cable_Apple":
                  $a['order'] = 8;
                  break;
              case "Light_bulb_key_ring":
                  $a['order'] = 9;
                  break;
              case "candy_machine":
                  $a['order'] = 10;
                  break;
              default:
                  $a['order'] = 999;
              }
          switch ($b) {
              case "1m_microUSB_cable":
                  $b['order'] = 1;
                  break;
              case "25cm_microUSB_cable":
                  $b['order'] = 2;
                  break;
              case "30cm_lightning_cable":
                  $b['order'] = 3;
                  break;
              case "1.5m_lightning_cable":
                  $b['order'] = 5;
                  break;
              case "1m_lightning_cable":
                  $b['order'] = 4;
                  break;
              case "1m_microUSB_upgrade_cable":
                  $b['order'] = 6;
                  break;
              case "hand_ring_cable_Android":
                  $b['order'] = 7;
                  break;
              case "hand_ring_cable_Apple":
                  $b['order'] = 8;
                  break;
              case "Light_bulb_key_ring":
                  $b['order'] = 9;
                  break;
              case "candy_machine":
                  $b['order'] = 10;
                  break;
              default:
                  $b['order'] = 999;
              }
  
          if ($a['order'] == $b['order']) {
              return 0;
          } elseif ($a['order'] &gt; $b['order']) {
              return -1;
          } else {
              return 1;
          }
      }
  ?&gt;
  </code></pre>
  
  <p>I want to reorder the array and I use </p>
  
  <pre><code>$glob = glob("a/*.php");
  include ("reorder.php");
  usort($glob, "reorder");
  foreach ($glob as $filename) {
          include ($filename);
          include ("templates/a.php");
      }
  </code></pre>
  
  <p>The dump of $glob:</p>
  
  <pre><code>array ( 0 =&gt; 'a/Light_bulb_key_ring.php', 1 =&gt; 'a/hand_ring_cable_Apple.php', 2 =&gt; 'a/hand_ring_cable_Android.php', 3 =&gt; 'a/1m_microUSB_upgrade_cable.php', 4 =&gt; 'a/1.5m_lightning_cable.php', 5 =&gt; 'a/1m_lightning_cable.php', 6 =&gt; 'a/30cm_lightning_cable.php', 7 =&gt; 'a/25cm_microUSB_cable.php', 8 =&gt; 'a/candy_machine.php', 9 =&gt; 'a/1m_microUSB_cable.php', )
  </code></pre>
  
  <p>I reorder the array from 1 to 9 is ok but when there is order 10, the order 10 will be after the order 1 but not the order 9. I don't know why? I hope someone can help me. Thank you!
  Sorry for my poor English.</p>
  
  <p>I am so sorry that I type it unclearly. Therefore, I create a image.</p>
  
  <p>The order now:
  <a href="http://nxu.biz/download/question.png" rel="nofollow">Image 1</a></p>
  
  <p>The expected order:
  <a href="http://nxu.biz/download/question_2.png" rel="nofollow">Image 2</a></p>