I have made edits to the AngularJS ordering example in my Plunker. The ordering works fine initially, but when I add a new person using code to periodically update the list of contacts, the new person gets added to the bottom without re-sorting. Is there a way to automatically re-sort the list every time a new user is added?
This is the code snippet I used to add new people while keeping the rest of the ordering mechanisms from Angular unchanged:
$scope.run_it = function() {
setTimeout($scope.run_it, 3000);
$scope.friends.push({name: 'New', phone: '000-0000', age: Math.floor((Math.random() * 100) + 1)});
$scope.$applyAsync();
};
setTimeout($scope.run_it, 3000);