What is the difference between the following two snippets when trying to orderBy via a function:
<li ng-repeat="str in arrOfStrings | orderBy: 'toString()'> {{str}} </li>
and
<li ng-repeat="person in people | orderBy: getSortKey()> {{person.firstName}} {{person.lastName}}: {{person.email}} </li>
$scope.getSortKey = function() {
return "lastName";
}
Also I wonder how the toString() method is helpful in sorting array of strings. See How to make orderby filter work on array of strings?