title: Sort a cell array of strings alphabetically by last name
body: <p>In Matlab, I have a cell array like:</p>
  
  <pre><code>names = {
      'John Doe',
      'Jane Watkins',
      'Jeremy Jason Taylor',
      'Roger Adrian'
      }
  </code></pre>
  
  <p>I would like to sort these such that the <strong>last names</strong> appear in alphabetical order. In my example, it would come out being:</p>
  
  <pre><code>names_sorted = {
      'Roger Adrian',
      'John Doe',
      'Jeremy Jason Taylor',
      'Jane Watkins'
      }
  </code></pre>
  
  <p>I know of inelegant ways of doing this. For instance, I could tokenize at space, make a separate <code>last_names</code> cell array, sort that, and apply the indexing to my original array. </p>
  
  <p>My question is, is there a better way?</p>
  
  <p>Because someone is sure to come up with that list of assumptions you can't make with regards to people names in a database, let me assure you that all my names are either <code>"FIRST MIDDLE LAST"</code> or <code>"FIRST LAST"</code>. I checked.</p>