Reputation: 295
Say for example I have:
ArrayList A; with values: "a","b", "c", "d", "e"
ArrayList B; with values: "3","1", "5", "2", "4"
Then I performed
Collections.sort(B);
so then ArrayList B becomes:
"1","2", "3", "4", "5"
Now I want to sort ArrayList A based on the sort in ArrayList B, I should get ArrayListA:
"b","d", "a", "e", "c"
How can I achieve that? Sorry I'm still new to Android. Any help would be appreciated.
Upvotes: 1
Views: 100
Reputation: 1622
Just put the data into the TreeMap
(which is a map sorted by natural ordering of its keys) and you're done.
Manual approach (if you want some programming practice) would be:
As you can see this question has nothing to do with Android, it's just a simple programming task.
Upvotes: 2