I need to sort my list according to the "Prioridade" attribute, and after that, I need to put all the elements isConsumido() = true to the end of the list, how would I do that?
I tried this, but is looped.
public void ordenar(List<ItemCultural> array) {
int i;
boolean a = true;
while (a) {
a = false;
for (i = 0; i < array.size() - 1; i++) {
if (array.get(i).getPrioridade() < array.get(i + 1).getPrioridade()) {
Collections.swap(array, i, i + 1);
a = true;
}
}
}
a = true;
while (a){
a = false;
for (i = 0; i < array.size() - 1; i++) {
if (array.get(i).isConsumido()) {
Collections.swap(array, i, array.size()-1);
a = true;
}
}
}
}
getPrioridade() returns a int, and isConsumido returns true or false. Thank you!