If I have a lexicographical sorted list of Java Strings [s1,s2,s3,s4, ...., sn], and then convert each String into a byte array using UTF-8 encoding bx = sx.getBytes("UTF-8"), is the list of byte arrays [b1,b2,b3,...bn] also lexicographical sorted?
If I have a lexicographical sorted list of Java Strings [s1,s2,s3,s4, …., sn] ,
Share
Yes. According to RFC 3239:
As Ian Roberts pointed out, this applies for “true UTF-8 (such as
String.getByteswill give you)”, but beware ofDataInputStream‘s fake UTF-8, which will sort [U+000000] after [U+000001] and [U+00F000] after [U+10FFFF].