I have an arraylist of arraylist, each inner arraylist contains 2 values, the first is an integer and the second is a string so essentially it would look like: {5, some text}, {12, some more text}, {3, even more text} etc, what I would like to do is take this and sort it so its in descending order of the largest integer to smallest, so the previous example then looks like: {12, some more text}, {5, some text}, {3, even more text}, any help would go a long way thanks in advance
I have an arraylist of arraylist, each inner arraylist contains 2 values, the first
Share
your data structure sounds like it is a ‘Map’ actually.
Maybe you should look into data structures, and collection interfaces and classes in particular…
If you still think that what you have is a ‘List’, then you should make a Collections.sort operation with right kind of Comparator or Comparable
Here is a solution to your data structure if the List is the right one;