title: Sort an associative array in php with multiple condition
body: <p>Consider following array</p>
  
  <pre><code>    $details = array( 
   array('lname'=&gt;'A', 'fname'=&gt;'P','membkey'=&gt;700,'head'=&gt;'y'),
   array('lname'=&gt;'B', 'fname'=&gt;'Q','membkey'=&gt;540,'head'=&gt;'n'),
   array('lname'=&gt;'C', 'fname'=&gt;'R','membkey'=&gt;700,'head'=&gt;'n'),
   array('lname'=&gt;'D', 'fname'=&gt;'S','membkey'=&gt;540,'head'=&gt;'y'),
   array('lname'=&gt;'E', 'fname'=&gt;'T','membkey'=&gt;700,'head'=&gt;'n')
      );
  </code></pre>
  
  <p>Here I would like to sort with head and membkey. Top element of same membkey element should have 'head=y' and echoed as,</p>
  
  <pre><code>    $details = array( 
   array('lname'=&gt;'A', 'fname'=&gt;'P','membkey'=&gt;700,'head'=&gt;'y'),
   array('lname'=&gt;'E', 'fname'=&gt;'T','membkey'=&gt;700,'head'=&gt;'n'),
   array('lname'=&gt;'C', 'fname'=&gt;'R','membkey'=&gt;700,'head'=&gt;'n'),
   array('lname'=&gt;'D', 'fname'=&gt;'S','membkey'=&gt;540,'head'=&gt;'y'),
   array('lname'=&gt;'B', 'fname'=&gt;'Q','membkey'=&gt;540,'head'=&gt;'n')
      );
  </code></pre>
  
  <p>I tried it as follows</p>
  
  <pre><code>    function orderbymemberKey( $a, $b ){
      if ( $a[membkey] == $b[membkey] )
          return 0;
      return($a[membkey] &lt; $b[membkey] )? -1 :1;
   }
   usort( $details, orderbymemberKey );
  and it successfully order by membkey.
  </code></pre>
  
  <p>Any suggestions please.</p>