ee.String.compareTo
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
Compares two strings lexicographically. הפונקציה מחזירה: את הערך 0 אם שני המחרוזות שוות לקסיקוגרפית, את הערך -1 אם string1 קטנה מ-string2, ואת הערך 1 אם string1 גדולה לקסיקוגרפית מ-string2.
שימוש | החזרות |
---|
String.compareTo(string2) | מספר שלם |
ארגומנט | סוג | פרטים |
---|
זה: string1 | מחרוזת | המחרוזת להשוואה. |
string2 | מחרוזת | המחרוזת להשוואה. |
דוגמאות
עורך הקוד (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
מידע על Python API ועל שימוש ב-geemap
לפיתוח אינטראקטיבי מופיע בדף
Python Environment.
import ee
import geemap.core as geemap
Colab (Python)
print(ee.String('a').compareTo('b').getInfo()) # -1
print(ee.String('a').compareTo('a').getInfo()) # 0
print(ee.String('b').compareTo('a').getInfo()) # 1
print(ee.String('a').compareTo(ee.String('b')).getInfo()) # -1
אלא אם צוין אחרת, התוכן של דף זה הוא ברישיון Creative Commons Attribution 4.0 ודוגמאות הקוד הן ברישיון Apache 2.0. לפרטים, ניתן לעיין במדיניות האתר Google Developers. Java הוא סימן מסחרי רשום של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-07-26 (שעון UTC).
[null,null,["עדכון אחרון: 2025-07-26 (שעון UTC)."],[[["\u003cp\u003e\u003ccode\u003ecompareTo\u003c/code\u003e lexicographically compares two strings, returning 0 if they are equal, -1 if the first string is less than the second, and 1 if the first string is greater than the second.\u003c/p\u003e\n"],["\u003cp\u003eThis method can be used on both client-side (JavaScript) and server-side (Python) Earth Engine environments and takes two string arguments for comparison.\u003c/p\u003e\n"],["\u003cp\u003eThe output is an Integer value (\u003ccode\u003e-1\u003c/code\u003e, \u003ccode\u003e0\u003c/code\u003e, or \u003ccode\u003e1\u003c/code\u003e) representing the comparison results.\u003c/p\u003e\n"]]],[],null,["# ee.String.compareTo\n\nCompares two strings lexicographically. Returns: the value 0 if the two strings are lexicographically equal; -1 if string1 is less than string2; and 1 if string1 is lexicographically greater than string2.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|-----------------------------|---------|\n| String.compareTo`(string2)` | Integer |\n\n| Argument | Type | Details |\n|-----------------|--------|----------------------------|\n| this: `string1` | String | The string to compare. |\n| `string2` | String | The string to be compared. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\nprint(ee.String('a').compareTo('b')); // -1\nprint(ee.String('a').compareTo('a')); // 0\nprint(ee.String('b').compareTo('a')); // 1\n\nprint(ee.String('a').compareTo(ee.String('b'))); // -1\n```\nPython setup\n\nSee the [Python Environment](/earth-engine/guides/python_install) page for information on the Python API and using\n`geemap` for interactive development. \n\n```python\nimport ee\nimport geemap.core as geemap\n```\n\n### Colab (Python)\n\n```python\nprint(ee.String('a').compareTo('b').getInfo()) # -1\nprint(ee.String('a').compareTo('a').getInfo()) # 0\nprint(ee.String('b').compareTo('a').getInfo()) # 1\n\nprint(ee.String('a').compareTo(ee.String('b')).getInfo()) # -1\n```"]]