I have an ArrayList of some class type, in particular:
ArrayList<RowColElem<T>> myList = new ArrayList<RowColElem<T>>();
myList.add(new RowColElem(4,4,11));
myList.add(new RowColElem(1,1,11));
myList.add(new RowColElem(3,3,11));
myList.add(new RowColElem(1,0,11));
myList.add(new RowColElem(3,0,11));
The output right now is:
[(4,4,11),(1,1,11),(3,3,11),(1,0,11),(3,0,11)]
Is it possible to sort myList from ascending order with regard to both row and col? So the output would be:
[(1,0,11),(1,1,11),(3,0,11),(3,3,11),(4,4,11)]
And is it possible to sort the list inside the class where it's located rather than implementing Comparable
or Comparator
in **RowColElem**
class?