How is the lexicographic order defined in Java especially in reference to special characters like !
, .
and so on?
An examplary order can be found here
But how does Java define it's order? I ask because I'm sorting Strings on Java and on Oracle and come up with different results and can't find the specification for the lexicographic order.
From the docs for
String.compareTo
:and
So basically, it treats each string like a sequence of 16-bit unsigned integers. No cultural awareness, no understanding of composite characters etc. If you want a more complex kind of sort, you should be looking at
Collator
.