Last Updated: June 6, 2026
Sorting a list of numbers is straightforward because Java already knows that 2 is less than 5. Sorting a list of products isn't, because Java has no built-in opinion about whether one product comes before another. The two interfaces Comparable and Comparator are how you teach Java that ordering. This lesson covers the contract each one has to satisfy, the common ways they get used, the chaining helpers that turn multi-key sorting into one readable line, and a few bugs that catch almost everyone the first time.