Product Site

5.1.7.52. compareTo

Performs a sort comparison of the target string to the string argument. If the two strings are equal, 0 is returned. If the target string is larger, 1 is returned. -1 if the string argument is the larger string. The comparison is performed starting at character n for length characters in both strings. n must be a positive whole number. If n is omitted, the comparison starts at the first character. length must be a non-negative whole number. If omitted, the comparison will take place to the end of the target string.
Example 5.90. String class — compareTo method
Say "abc"~compareTo("abc")         -->    0
Say "b"~compareTo("a")             -->    1
Say "a"~compareTo("b")             -->   -1
Say "abc"~compareTo("aBc")         -->    1
Say "aBc"~compareTo("abc")         -->   -1
Say "000abc000"~compareTo("111abc111", 4, 3)  --> 0