What order are the strings printed in?
List<String> words = new ArrayList<>(List.of("bb", "a", "ccc", "dd"));
words.sort(Comparator.comparingInt(String::length)
.thenComparing(Comparator.reverseOrder()));
words.forEach(System.out::println);