【发布时间】:2018-12-20 22:02:08
【问题描述】:
我有一个“Couple”类,没有什么比 String 和 double 更特别的了:
public class Couple{
public String mot;
public double indice;
public Couple(){
this.mot = "";
this.indice = 0;
}
public Couple(String t, double q){
this.mot = t;
this.indice = q;
}
}
现在,假设我有一个 Couple 数组。 我想按每个值的双精度对该数组进行排序。 例如:
排序前:
{("hi",3), ("hello",1),("Good",2),("nice",0)}
按照每对的double值排序后:
{("nice",0),("hello",1),("Good",2),("hi",3)}
【问题讨论】:
-
有多种方法。您尝试过什么?你做了什么研究?