Sorting a double value of an object within an arrayList
问题 I'm trying to sort my custom class chromosome by the value of their score attribute which is a double. These chromosomes are stored within an ArrayList. I know I have to use a comparator but I've read so many differing opinions online in the last hour that I'm utterly confused. Attached is my code, if someone could point me in the right direction I would be much appreciated. public class Chromosome { public Gene[] genes; public double score; public Chromosome(int l) { genes = new Gene[l]; }