title: usort function in a class
body: <p>I have a function which sorts data in a multidimensional array, as shown below:  </p>
  
  <pre><code>&lt;?php  
  $data = array();  
  $data[] = array("name" =&gt; "James");  
  $data[] = array("name" =&gt; "andrew");  
  $data[] = array("name" =&gt; "Fred");  
  
  function cmp($a, $b)  
  {  
      return strcasecmp($a["name"], $b["name"]);  
  }  
  
  usort($data, "cmp");  
  
  var_dump($data);  
  ?&gt;  
  </code></pre>
  
  <p>When i run this, it works as expected, returning the data ordered by name, ascending. However, I need to use this in a class. </p>
  
  <pre><code>&lt;?php
  class myClass  
  {  
      function getData()  
      {  
          // gets all data
          $this -&gt; changeOrder($data);
      }  
  
      function changeOrder(&amp;$data)  
      {  
           usort($data, "order_new");
      }
  
      function order_new($a, $b)  
      {  
          return strcasecmp($a["name"], $b["name"]);  
      }
  }
  ?&gt;
  </code></pre>
  
  <p>When I use this, i get the following warning: <strong>Warning: usort() expects parameter 2 to be a valid callback, function 'order_new' not found or invalid function name.</strong></p>
  
  <p>When i put the order_new function in the changeOrder function it works fine, but I have problems with <strong>Fatal error: Cannot redeclare order_new()</strong>, so i cannot use that. Any suggestions?</p>