If I have a list of elements I would like to sort, Java offers two ways to go about this.
For example, lets say I have a list of Movie objects and I’d like to sort
It depends who controls the ordering. If the ordering of an object is an implementation detail of the object, the Comparable is more appropriate. If the ordering of the objects is controlled by the caller, then Comparator is more appropriate.
Comparable
Comparator