@Override
public String createExport(ArrayList<Integer> allIdList) {
ArrayList<Answer> allAnswer = new ArrayList<>();
for(int elem : vvtList) {
allAnswer.addAll(findById(elem).getAnswer());
}
for(Answer elem : allAnswer) {
allAnswer.sort(elem.getFirstSortId()); //Doesn't work
allAnswer.sort(elem.getSecondSortId()); //Doesn't work
}
return allAnswer.toString;
}
I created my own class Anwser. It contains two Integers, firstSortId and secondSortId. I want to sort the allAnswer-ArrayList by them. At the moment the Array List is pure chaos.
firstSortId 76 secondSortId 2
firstSortId 57 secondSortId 1
firstSortId 36 secondSortId 2
The result should be
firstSortId 57 secondSortId 1
firstSortId 36 secondSortId 2
firstSortId 76 secondSortId 2
How can I sort the array by one, and then by two Integers inside them?