I have a string that is pipe separated and I wanted to spilt it into a list and sort it in the reverse order.
But I see that the order is not maintained. Whats the problem here ?
String str = "Chicago|Indianapolis|Boston|Houston";
List<String> splitList= Stream.of(str.split("\\|"))
.map(String::trim)
.sorted(Collections.reverseOrder())
.limit(30)
.collect(toList());
//Expected [Houston,Boston,Indianapolis,Chicago]
//Got [Indianapolis,Houston,Boston,Chicago]