I am calling the sorted method on a stream. And the java doc says:
"Sorted method returns a stream consisting of the elements of this stream, sorted according to natural order."
But when I run the code below:
List<String> list = new ArrayList<String>();
list.add("b");
list.add("a");
list.add("z");
list.add("p");
list.stream().sorted();
System.out.println(list);
I am getting output as
[b, a, z, p]
Why am I not getting the output of a natural sort?