I have implemented bubble sort to sort a two dimensional java long [][]
but my god is it slow, I will be needing the fasted algorithm possible as
i will be generating a array of the max heap size jvm will allow me,
So i think the best and fastest way would be to use the inbuild java Arrays.sort
I dont mind if it can only sort on column one as i can change my program to suit,
I came across this but am not to familar with comaparator,
this will allow me to sort a dimensional array of integers, does anyone know how to change this to allow longs?, i did thinker around with it with no joy yet.
int d2 [][] = {{1,43},{26,98},{44,398},{11,34},{17,32}};
java.util.Arrays.sort(d2, new java.util.Comparator<int[]>() {
public int compare(int[] a, int[] b) {
return b[0] - a[0];
}
});
i want to sort say
long d2L [][] = {{1,43},{26,98},{44,398},{11,34},{17,32}};
casting is not an option as the numbers a massive
Also if anyone thinks theres a faster method to sort im all ears:)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…