Since 1.3.0-rc.5
Since AngularJS 1.3.0-rc.5, the orderBy
filter (see the documentation) will automatically sort the array using its items if no additional parameters are provided.
<li ng-repeat="item in items | orderBy">{{item}}</li>
Before 1.3.0-rc.5
The orderBy
filter (see the historical documentation) can also take a function as second parameter, whose return value will be compared using the <
, =
and >
operator.
You can simply use the angular.identity
(see the documentation) for that purpose:
$scope.identity = angular.identity;
<li ng-repeat="item in items | orderBy:identity">{{item}}</li>