I had this:
Comparator<Item> ignoreLeadingThe = new Comparator<Item>() {
public int compare(Item a, Item b) {
String newA = a.name.replaceAll("(?i)^the\\s+", "");
String newB = b.name.replaceAll("(?i)^the\\s+", "");
return newA.compareToIgnoreCase(newB);
}
};
Array.sort(MyItemArrayOfObjects, ignoreLeadingThe);
I stopped using Arrays and am now using ArrayList. So when I do this:
Collections.sort(MyItemArrayListOfObjects, ignoreLeadingThe);
I can't even figure out the pattern that it is now sorting by. Can I do a clean switch like this? (It is entirely possible I broke this with something not mentioned above, if this is right, then that's all I need to know)
Note: Originally, with the Arrays I was simply trying to alphabetize a list and ignore the leading "The". It's for an Android app. Each List row Item data was wrapped in an Object that I am passing to an ArrayAdapter. I simply wanted to take an ArrayList inside that object and alphabetize it. So essentially, it's an ArrayList with a few ArrayList inside it.