public static void main(String args[]) {
int g=0;int x=0;int y=0;
List<Integer> temporaryOpenList = new ArrayList<>();
List<ArrayList> listToSort = new ArrayList<>();
for(int i=3 ; i>0 ; i--) {
g = g + i;
x = x + i;
y = y + i;
temporaryOpenList.add(g);
temporaryOpenList.add(x);
temporaryOpenList.add(y);
ArrayList<Integer> openList = new ArrayList<Integer>(temporaryOpenList);
temporaryOpenList.clear();
listToSort.add(openList);
System.out.println(listToSort);
}
The output will be :
[[3, 3, 3]]
[[3, 3, 3], [5, 5, 5]]
[[3, 3, 3], [5, 5, 5], [6, 6, 6]]
Now I want to sort listToSort based upon g value means the 1st value of the value triplet [g,x,y].But collections.sort(listToSort) command doesn't work
Collections.sort.