Possible Duplicate:
How do I sort two arrays in relation to each other?
I have 2 two String[]
arrays. I want to sort 2nd array with index same with the 1st array.
private void checkDatabase(String keyword, String origins) {
List<RSList> rslist = db.getAllRSListsByType(keyword);
total = rslist.toArray().length;
String[] titlearray = new String[total];
String[] distance = new String[total];
int i = 0;
for (RSList cn : rslist) {
titlearray[i] = cn.getName();
String origin = origins;
String destination = cn.getGlat() + "," + cn.getGlon();
distance[i] = checkDataToGoogle(origin, destination);
Log.i("Name: ", distance[i]);
i++;
}
Arrays.sort(distance);
filldata(titlearray, distance);
}
I want to make index of titlearray
same with distance
array, I already sort the distance
array first, but I don't know how to make order of titlearray
same with distance
.
Can anyone give me advice?