I've only started learning Java about 3 months ago and this is my first post here, so please bear with me.
I have multiple ArrayLists built from parsed XML that are directly related to each other in order. The arrays are later put into a single mapped ArrayList (groupData) to be read with a SimpleAdapter which creates the list in the Android GUI.
What I want to do is sort the list in alphabetical order based on one array (arr_title) and the other arrays stay in synchronized order to it. It doesn't matter where the sorting happens as long as the final displayed list is sorted. I expect it would be best to sort the mapped array once it's built. The simpler or easier to understand the code the better, but don't want the sorting to go very slow either. I have about 140 objects per array, but that could expand considering the XML is pulled from the web.
I've spent hours searching Google and tried a number of things with little progress. Collections.sort(arr_title) will sort the one array as I want it, but then the other arrays don't match up and doing the same thing to the other arrays obviously just sorts them individually as I don't want. I've noticed mention of using the TreeMap type and Comparator for similar sorting, but couldn't figure out how to use them in this case probably because the examples didn't provide a big enough picture for me to understand.
The sample below is where most of the stuff happens after the separate arrays are created.
List<Map<String, String>> groupData = new ArrayList<Map<String, String>>();
Map<String, String> group;
int item = 0;
do {
group = new HashMap<String, String>();
group.put("title", arr_title.get(item));
group.put("desc", arr_desc.get(item));
group.put("num", Integer.toString(arr_num.get(item)));
groupData.add(group);
item++;
} while (item < arr_num.size());
SimpleAdapter adapter = new SimpleAdapter(this, groupData, android.R.layout.simple_list_item_2, new String[] {"title", "desc", "num"}, new int[]{android.R.id.text1, android.R.id.text2});
setListAdapter(adapter);