I have an array of objects, whose elements as displayed using ng-repeat from AngularJS. Each object has a priority_int integer value, and I know that I can sort the array is descending order with:
array.sort(function(a,b){
return b.priority_int - a.priority_int;
}
Currently, I'm adding everything to the array, before sorting by priority_int in descending order, and then displaying with ng-repeat.
Out of curiousity, how can I sort every time I push an object into the array?