返回一定是要double数组么还是?
如果要升序排列,就把那个比较那个方法里面1和-1调换就可以了
import java.util.Arrays;
import java.util.Comparator;
public class Du {
public static void main(String[] args) {
double ch1[][] = new double[][] { { 0.25, 100 }, { 0.75, 80 },{ 0.5, 120 }, { 0.8, 150 } };
AryItem[] itemAry = new AryItem[ch1.length];
for (int i = 0; i {
public int compare(AryItem o1, AryItem o2) {
if (o1.getSecondElement() < o2.getSecondElement()) {
return 1;
} else if (o1.getSecondElement() == o2.getSecondElement()) {
return 0;
} else {
return -1;
}
}
}
class AryItem {
public double firstElement;
public double secondElement;
public AryItem(double first, double second) {
this.firstElement = first;
this.secondElement = second;
}
public double getSecondElement() {
return secondElement;
}
public String toString() {
return firstElement + "\t" + secondElement;
}
}
------------------
0.8150.0
0.5120.0
0.25100.0
0.7580.0