thats because you are comparing strings here, and not as intended integers. Thus, the actual order in the set: 1, 10, 2, 3, 4!
Use generics: NavigableSet<Integer> original = new TreeSet<>(); and add the values ββas integers: original.add(1); etc.
source share