Makky Makky - 1 year ago 128
Java Question

Comparing strings by their alphabetical order

String s1 = "Project";
String s2 = "Sunject";

I want to compare the two above string by their alphabetic order (which in this case "Project" then "Sunject" as "P" comes before "S").
Does anyone know how to do that in Java?

Answer Source

String.compareTo might or might not be what you need.

Take a look at this link if you need localized ordering of strings.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download