so I am trying to sort an ArrayList as the title says. I have A Superclass called Thing that has 2 different subclasses, a HeavyThing and a LightThing. The ArrayList contains just the 2 subclasses and I need to sort it so the HeavyThing comes before the LightThing.
So far I got the sort method to work for the name of the Things but I was unable to sort it by subclass.
this.collThings.sort(new Comparator<Thing>() {
public int compare(Thing t1, Thing t2) {
return Integer.valueOf(t1.getName().compareTo(t2.getName()));
}
});
This is how I sorted it by name.