Below is the sort criteria from A to Z: 1) special characters 2) numbers 3) alphabet
For example:-
$scope.cards = ["815 BRAZOS ST AUSTIN TX 78701","7745 CHEVY CHASE DR AUSTIN TX 78752","701 BRAZOS ST AUSTIN TX 78701","555 ROUND ROCK WEST DR ROUND ROCK TX 78681","400 W 15TH ST AUSTIN TX 78701"]
Expected result after sorting:-
400 W 15TH ST AUSTIN TX 78701
555 ROUND ROCK WEST DR ROUND ROCK TX 78681
701 BRAZOS ST AUSTIN TX 78701
815 BRAZOS ST AUSTIN TX 78701
7745 CHEVY CHASE DR AUSTIN TX 78752
I want to achieve this using Angular orderBy filter. As in JS custom sort function, we got two arguments and by manipulating that we can return >0, <0 and 0 to achieve custom sort.
My Attempt
<div ng-controller="MyCtrl">
<ul ng-repeat="card in cards | orderBy:myValueFunction">
<li>{{card}}</li>
</ul>
</div>
JS
var myApp = angular.module('myApp', []);
function MyCtrl($scope) {
$scope.cards = ["815 BRAZOS ST AUSTIN TX 78701","7745 CHEVY CHASE DR AUSTIN TX 78752","701 BRAZOS ST AUSTIN TX 78701","555 ROUND ROCK WEST DR ROUND ROCK TX 78681","400 W 15TH ST AUSTIN TX 78701"]
$scope.myValueFunction = function(card,card1) {
console.log(card);
console.log(card1);
return card;
}
}
Thanks