For lists, we use the Collections.sort(List) method. What if we want to sort a HashSet?
Collections.sort(List)
HashSet
You can use Java 8 collectors and TreeSet
list.stream().collect(Collectors.toCollection(TreeSet::new))