I know that Collections.sort(myArrayList)
can sort an arraylist alphabetically when they are strings, but what about when they are something more complex such as a data object containing two or more variables including a String
. Is there a way to sort them then?
If there isn't a way with Collections
then I can imagine making a for loop or standard sorting algorithm to look at the strings variable of each object and move the object's index in the array.
But I was wondering mainly if I overlooked something about the Collections
methods