Question:
$scope.auxiliar.minimo = $scope.blocos[i].tamanhoTotal - processo.tamanho;
$scope.auxiliar.posicaoBlocoLivre = $scope.blocos[i];
$scope.menores.push($scope.auxiliar);
I want to sort my "smallest" vector incrementally by the object attribute: "$scope.auxiliar.minimo"
Answer:
Here's a way to organize the array for use in JS by creating a function to be passed as a parameter in sort.
var sortByMinimo = function(a, b) {
if (a.minimo < b.minimo) {
return 1;
}
if (a.minimo > b.minimo) {
return -1;
}
return 0;
};
$scope.menores.sort(sortByMinimo);
You can use the AngularJs ways suggested in the other answer, especially if you just want to organize in the view.