can you please let me know why below code returns the set sorted order given an unsorted array?
Stream<Integer> s = Stream.of(2, 3, 1, 4, 5);
Set<Integer> mySet = s.collect(Collectors.toSet());
System.out.println(mySet);
O/p
1, 2, 3, 4, 5
This doesn't happen if I use List instead of Set. Also the sorting is not always correct when there are negative numbers in the input. Is there any inbuilt functionality to sort the Set?