Implement the Comparator interface to define custom sorting logic for collections.
Source Code
List words = Arrays.asList("Apple", "Banana", "Cherry");
Collections.sort(words, (String a, String b) -> b.compareTo(a)); // Sort in reverse order
System.out.println(words);