As mentioned you can sort by:
- Making your object implement
Comparable
- Or pass a
Comparator
toCollections.sort
If you do both, the Comparable
will be ignored and Comparator
will be used. This helps that the value objects has their own logical Comparable
which is most reasonable sort for your value object, while each individual use case has its own implementation.