Sorting ArrayList of Arraylist in java

后端 未结 7 980
忘掉有多难
忘掉有多难 2021-01-19 03:16

I have an ArrayList of ArrayList of String.

In Outer ArrayList on each index each Inner ArrayList has four items have four parameters.

  1. Contacts Id
7条回答
  •  北海茫月
    2021-01-19 03:48

    I feel bad posting this, because List would be the much better choice. Something like this would be possible, though:

    ArrayList> yourList = ...
    Collections.sort(yourList, new Comparator>() {
        @Override
        public int compare(ArrayList one, ArrayList two) {
            return one.get(1).compareTo(two.get(1));
        }
    });
    

提交回复
热议问题