I have a class, which I have simplified to this:
final class Thing { private final int value; public Thing(int value) { this.value = value;
When comparing Java primitives, it is advisable to convert them to their Object counterparts and rely on their compareTo() methods.
compareTo()
In this case you can do:
return Integer.valueOf(a.getValue()).compareTo(b.getValue())
When in doubt, use a well-tested library.