I've done a basic table sorting application using angular, sorting is doing but the problem is that i'm not getting the values sorted in ASCII value
can anyone please tell me how to do it
html
<div ng-app ng-controller="ArrayController">
<table>
<th ng-repeat="header in headers">
<a ng-click="sort_by(header)">{{ headers[$index] }}</a>
</th>
<tr ng-repeat="arr in records |orderBy:sortingOrder:reverse">
<td ng-repeat="val in arr" ng-bind-html-unsafe="arr[headers[$index]]"></td>
</tr>
</table>
</div>
script
function ArrayController($scope) {
$scope.headers = ['col1', 'col2'];
$scope.records = [{col1: 'a1', col2: 'd1'}, {col1: 'c2', col2: 'A2'}, {col1: 'b3', col2: 'c3'}, {col1: 'd4', col2: 'a1'}];
$scope.reverse = true;
$scope.sort_by = function(newSortingOrder)
{
if ($scope.sortingOrder === newSortingOrder)
{
$scope.reverse = !$scope.reverse;
}
$scope.sortingOrder = newSortingOrder;
};
}