I have:
String[] subdivisions = {"K1","K1\\SK1","K2","K2\\SK1\\SSK1"};
I sorted:
Arrays.stream(subdivisions).sorted(Comparator.reverseOrder()).forEach(System.out::println);
I get:
K2\SK1\SSK1
K2
K1\SK1
K1
But I need to sort this way:
K2
K2\SK1\SSK1
K1
K1\SK1
How can I change sort condition? How do I write the sort correctly?
reverseOrder()is not a reversing operation, it's a descending natural-order sort.