Assuming that each array has a index mapping to the other, you will need a proxy array which is used to maintain that mapping, then sort this array accordingly, for example...
The mapping array acts as the master indexer, even though it's own order may change, each entry still points to the associated position in the other arrays that it represents...
String[] distance = {"1", "3", "6", "7", "9"};
String[] name = {"Joel", "John", "Joe", "Jill", "Jane"};
String[] values = {"1.5", "2.3", "5.6", "7.1", "6.5"};
// Mapping array...
Integer[] proxyLookup = new Integer[]{0, 1, 2, 3, 4};
System.out.println("Unsorted...");
for (int index : proxyLookup) {
System.out.println(name[index] + "; " + distance[index] + "; " + values[index]);
}
Arrays.sort(proxyLookup, new Comparator<Integer>() {
@Override
public int compare(Integer o1, Integer o2) {
return name[o1].compareTo(name[o2]);
}
});
System.out.println("Sorted...");
for (int index : proxyLookup) {
System.out.println(name[index] + "; " + distance[index] + "; " + values[index]);
}
This will output...
Unsorted...
Joel; 1; 1.5
John; 3; 2.3
Joe; 6; 5.6
Jill; 7; 7.1
Jane; 9; 6.5
Sorted...
Jane; 9; 6.5
Jill; 7; 7.1
Joe; 6; 5.6
Joel; 1; 1.5
John; 3; 2.3
Note, that the order that the values are listed are different, but the associated data remains the same...
A simpler solution would be to encapsulate the data into a single Object
which maintained the properties. This would greatly simplify the problem