I have 2 arraylists, one of type String and the other is a custom class Person.
List names = new ArrayList<String>();
List people = new ArrayList<Person>();
Both lists are populated like so:
names.add("bob");
names.add("joe");
names.add("tom");
people.add(new Person("joe")); //Assuming Person has a name property
people.add(new Person("tom"));
people.add(new Person("bob"));
Notice that the same names have been used in both lists, but added in different order. How can I sort the people arraylist in the same order as the names?
namesguaranteed to be alphabetical?peoplearray to match the order in thenames" array?namesis not guaranteed alphabetical.