Here's an example of what I'm trying to do:
public class Item {
private int worth;
public Item(int worth) {
this.worth = worth;
}
public int getWorth() { return worth; }
}
public class Foo {
public Foo() {
List<Item> items = new ArrayList<>();
items.add(new Item(50));
items.add(new Item(892));
items.add(new Item(12));
// Sort?
}
}
So that the items will be ordered like so
List{
Item(892)
Item(50)
Item(12)
}
Not exactly sure where I should go from here, the Arrays.sort() method would be amazing if I could figure out how to sort it by an integer inside of the class.