I've been attempting to find a way to sort a multidensional array. It is a two dimensional array containing distances and city names. For example:
String idArray[][];
idArray = new String[3][2];
with the following values:
10,name1
30,name2
4,name3
I want to sort the entire array based on the array column n,0 containing the distances. I tried the Arrays.sort method but it appears to work only on arrays with one dimension.
Anybody have any ideas. I've been looking at the collections framework and ArrayLists but I havent really seen an easy answer. I am currently saving each value to it's own array and doing a bubble sort on both arrays simultaneously. Hoping their is a better way.
Thanks
String idArray[][];
idArray = new String[3][2];
with the following values:
10,name1
30,name2
4,name3
I want to sort the entire array based on the array column n,0 containing the distances. I tried the Arrays.sort method but it appears to work only on arrays with one dimension.
Anybody have any ideas. I've been looking at the collections framework and ArrayLists but I havent really seen an easy answer. I am currently saving each value to it's own array and doing a bubble sort on both arrays simultaneously. Hoping their is a better way.
Thanks