对数组列表中对象的双精度值进行排序
我正在尝试按其分数属性的值对我的自定义类染色体进行排序,该值是双精度。这些染色体存储在ArrayList中。我知道我必须使用比较器,但我在过去的一个小时里在网上读到了很多不同的观点,我完全困惑了。
附件是我的代码,如果有人能为我指出正确的方向,我将不胜感激。
public class Chromosome
{
    public Gene[] genes;
    public double score;
    public Chromosome(int l)
    {
        genes = new Gene[l]; 
    }
    public int getLength()
    {
        return genes.length;
    }
    public void printChromo()
    {
        for(int i=0;i<this.genes.length;i++)
        {
            System.out.println(""+this.genes[i].teacher+","+
                this.genes[i].lecture+","+
                this.genes[i].room+","+
                this.genes[i].time+"");
        }   
    }
    public void setScore(double score)
    {
        this.score=score;
    }
    public double getScore()
    {
        return this.score;
    }
}
不知道这会有什么不同,但分数只能是0.0到1.0之间的双倍