title: Creating orderBy expression that runs a function in ng-repeat
body: <p>I have an array of people with <code>firstName</code>s and <code>lastName</code>s. I'm want to <code>ng-repeat</code> through the them and then <code>orderBy: 'lastName'</code>. This works fine.</p>
  
  <p>However, some <code>person</code>s in my <code>people</code> array only have a first name. I want to be able to order by the last name, and whenever it finds someone with a <em>only</em> a first name, to treat that first name as a last name, ie. the initial of the first name is alphabetised with the rest of the last names (hope that makes sense...)</p>
  
  <p>Is it a case of writing a function in my controller and then calling that variable in the <code>orderBy:</code> expression? I've tried that and it didn't work:</p>
  
  <p>Controller:</p>
  
  <pre><code>self.nameOrder = function(thisOne) {
      if (thisOne.lastName == null) {
          thisOne.firstName == thisOne.lastName;
      }
  }
  </code></pre>
  
  <p>View:</p>
  
  <pre><code>&lt;p ng-repeat="name in people | orderBy: 'lastName.nameOrder()' "&gt;{{lastName}}&lt;/p&gt;
  </code></pre>
  
  <p>I'm aware the above is probably totally wrong, but I thought it better to at least show what I've been attempting so it's clearer what my intentions are :/</p>
  
  <p>Any help would be appreciated. Thanks in advance.</p>