title: Using a Static Class Method to *Quickly* Sort an Array By Key Value in PHP
body: <p>This question is different than others, as it's focus is on sorting an array with a static class method rather than the typical procedural approach.</p>
  
  <p>I am look for a very performant way to implement the function sortByKeyValue below. Other somewhat related answers are focused on getting the job done, this question is more about getting the job done and getting it done very quickly (as a static method).</p>
  
  <p>Anyone want to take a crack at it? I'll probably throw some bounty on this question to squeeze out the performance junkies. :)</p>
  
  <pre><code>&lt;?php
  
  $data = array(
     array('name' =&gt; 'B', 'cheesy' =&gt; 'bacon'),
     array('name' =&gt; 'C', 'delicious' =&gt; 'tacos'),
     array('name' =&gt; 'A', 'lovely' =&gt; 'viddles'),
  );
  
  class MyArray {
  
      public static function sortByKeyValue($array, $key, $direction = 'ASC') {
          // Do the thing
          // Help me!
  
          return $array;
      }
  
  }
  
  $data = MyArray::sortByKeyValue($data, 'name');
  
  // Should output the name key in order
  // I am not including the garbage keys I threw in, but they should be there too)
  // [{"name": "A"},{"name": "B"},{"name": "C"}]
  ?&gt;
  </code></pre>