I have a dataset for Ex:
$scope.friends =
[{name:'John', score:'10'},
{name:'Mary', score:'19'},
{name:'Mike', score:'-21'},
{name:'Adam', score:'-35'},
{name:'Julie', score:'29'}];
}]);
i use this data as a source of ng-repeat,
<tr ng-repeat="friend in friends | orderBy:'-score' ">
<td>{{friend.name}}</td>
<td>{{friend.score}}</td>
</tr>
I want to sort the friends according to score in descending order. like below,
Name Score
-------------
Julie 29
Mary 19
John 10
Mike -21
Adam -35
but i get the output as,
Name Score
-------------
Julie 29
Mary 19
John 10
Adam -35
Mike -21
here is a Demo Plunker
note that -21 and -35 are not in correct order in the output, and this is because the score property is a String value. If i change it to int value then all are working as expected. how to overcome this, and please consider that i'am not able to change the type of the score property.