I am struggling to display sorted data using ng-repeat. Although I looked at this example for guidance
Order by Object key in ng-repeat
applying the same filter did not yield the desired output. My list remains unsorted.
You can view my code here: http://plnkr.co/edit/qFaBYnwCVTZJZSiw6hdD?p=preview
var app = angular.module('app', []);
app.controller('MyCtrl',function($scope){
$scope.lines = {
"a": {name:"bb"},
"aa":{name: 'aa'},
"zz": {name:"zz"},
"oo":{name: 'oo'},
"kk": {name:"k"},
"j":{name: "a"},
"n": {name:"n"},
"c":{name: "c"}
}
})
app.filter('toArray', function() {
return function(obj) {
if (!(obj instanceof Object)) return obj;
return _.map(obj, function(val, key) {
return Object.defineProperty(val, '$key', {__proto__: null, value: key} );
});
}
});