Compares two strings lexicographically. Returns: the value 0 if the two strings are lexicographically equal; a value less than 0 if string1 is less than string2; and a value greater than 0 if string1 is lexicographically greater than string2.
Usage | Returns |
---|---|
String.compareTo(string2) | Integer |
Argument | Type | Details |
---|---|---|
this: string1 | String | The string to compare. |
string2 | String | The string to be compared. |
Examples
JavaScript
print(ee.String('a').compareTo('b')); // -1 print(ee.String('a').compareTo('a')); // 0 print(ee.String('b').compareTo('a')); // 1 print(ee.String('a').compareTo(ee.String('b'))); // -1
Python
# Your example goes here!