So i am making a program that needs to handle multiple arrays. Is there any way to sort all these arrays to reflect the sorting of one array? These values are at the same in
A better/more object oriented approach could be to have an object holding each of the 3 fields and having it sortable on whichever field you need.
public static class MyObject implements Comparable {
public int distance;
public String name;
public float value;
// Replace this with whichever field is needed
@Override
public int compareTo(MyObject o) {
// If it's the String
return this.name.compareTo(o.name);
// If it's one of the values
return this.distance - o.distance;
}
}