I have an ArrayList of ArrayList of String.
In Outer ArrayList on each index each Inner ArrayList has four items have four parameters.
Assuming your Lists in your List has Strings in the order id, name, address and number (i.e. name is at index 1), you can use a Comparator
, as follows:
List> list;
Collections.sort(list, new Comparator> () {
@Override
public int compare(List a, List b) {
return a.get(1).compareTo(b.get(1));
}
});
Incidentally, it matters not that you are using ArrayList
: It is good programming practice to declare variables using the abstract type, i.e. List
(as I have in this code).