title: Sorting array in 1 order by 2 keys
body: <p>I have an array like so.</p>
  
  <pre><code>  [Badi Assad] =&gt; Array
      (
          [last_name] =&gt; Assad
          [first_name] =&gt; Badi
          [artist_name] =&gt; 
          [asterick] =&gt; *
          [slug] =&gt; badiassad
      )
  
  [Ben Taylor] =&gt; Array
      (
          [last_name] =&gt; Taylor
          [first_name] =&gt; Ben
          [artist_name] =&gt; Ben Taylor
          [asterick] =&gt; *
          [slug] =&gt; bentaylor
      )
  
  [Beverly] =&gt; Array
      (
          [last_name] =&gt; Hills
          [first_name] =&gt; Beverly
          [artist_name] =&gt; Beverly
          [asterick] =&gt; 
          [slug] =&gt; Eedih
      )
  
  [Bruce Cockburn] =&gt; Array
      (
          [last_name] =&gt; Cockburn
          [first_name] =&gt; Bruce
          [artist_name] =&gt; Bruce Cockburn
          [asterick] =&gt; *
          [slug] =&gt; brucecockburn
      )
  
  [Bohème] =&gt; Array
      (
          [last_name] =&gt; 
          [first_name] =&gt; Cassidy
          [artist_name] =&gt; Bohème
          [asterick] =&gt; *
          [slug] =&gt; cassidy
      )
  </code></pre>
  
  <p>How would I sort is so it it would be in order with the last name and artist name in order where the last name trumps the artist name except when it is empty.</p>
  
  <p>The resulting should look like this.</p>
  
  <pre><code>  [Badi Assad] =&gt; Array
      (
          [last_name] =&gt; Assad
          [first_name] =&gt; Badi
          [artist_name] =&gt; 
          [asterick] =&gt; *
          [slug] =&gt; badiassad
      )
  [Bohème] =&gt; Array
      (
          [last_name] =&gt; 
          [first_name] =&gt; Cassidy
          [artist_name] =&gt; Bohème
          [asterick] =&gt; *
          [slug] =&gt; cassidy
      )
  [Bruce Cockburn] =&gt; Array
      (
          [last_name] =&gt; Cockburn
          [first_name] =&gt; Bruce
          [artist_name] =&gt; Bruce Cockburn
          [asterick] =&gt; *
          [slug] =&gt; brucecockburn
      )
  
  [Beverly] =&gt; Array
      (
          [last_name] =&gt; Hills
          [first_name] =&gt; Beverly
          [artist_name] =&gt; Beverly
          [asterick] =&gt; 
          [slug] =&gt; Eedih
      )
  [Ben Taylor] =&gt; Array
      (
          [last_name] =&gt; Taylor
          [first_name] =&gt; Ben
          [artist_name] =&gt; Ben Taylor
          [asterick] =&gt; *
          [slug] =&gt; bentaylor
      )
  </code></pre>
  
  <p>I am currently trying this.</p>
  
  <pre><code>    $newartists = array();
  foreach($users as $k =&gt; $v)
   {
      $name = (strlen($v['artist_name']) &gt; 0) ? $v['artist_name'] : $v['first_name'].' '.$v['last_name'];
      $newartists[$name]['last_name'] = $v['last_name'];
      $newartists[$name]['first_name'] = $v['first_name'];
      $newartists[$name]['artist_name'] = $v['artist_name'];
      $newartists[$name]['asterick'] = $ask;
      $newartists[$name]['slug'] = $v['slug'];
  }                    
  $sort = array();
  foreach($newartists as $k=&gt;$v) {
      $sort['artist_name'][$k] = $v['artist_name'];
      $sort['last_name'][$k] = $v['last_name'];
  }
  
  array_multisort( $sort['last_name'], SORT_ASC,$sort['artist_name'], SORT_ASC, $newartists);
  </code></pre>
  
  <p>Thanks!</p>