orderBy over simple array?

angularjs

Solution

You can declare simple `proxy` function within your controller and use it:

Controller:

$scope.proxy = function(x) { return x; }

HTML:

<tr ng-repeat="t in telcodes | orderBy: proxy">

However, it gives you string comparison (demo).

To get standard numeric comparison modify `proxy` a little (demo):

$scope.proxy = function(x) { return x * 1; }

Problem

I have an array like this: ``` $scope.telcodes = ['44', '01', '221', '335']; ``` How do I use orderBy on a simple array like this to produce an ordered list starting from 01? I know how to do this on an array containing objects but not on simple arrays like the above. ``` <li data-ng-repeat="telcode in telcodes | orderBy:????:false track by $index"> ```

Original source

Related problems