ee.String.compareTo
संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
यह फ़ंक्शन, दो स्ट्रिंग की लेक्सिकोग्राफ़िक तुलना करता है. यह फ़ंक्शन, इन वैल्यू को दिखाता है: अगर दोनों स्ट्रिंग लेक्सिकोग्राफ़िक तौर पर बराबर हैं, तो 0; अगर string1, string2 से कम है, तो -1; और अगर string1, string2 से लेक्सिकोग्राफ़िक तौर पर ज़्यादा है, तो 1.
इस्तेमाल | रिटर्न |
---|
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 एनवायरमेंट पेज देखें.
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 License के तहत और कोड के नमूनों को Apache 2.0 License के तहत लाइसेंस मिला है. ज़्यादा जानकारी के लिए, Google Developers साइट नीतियां देखें. Oracle और/या इससे जुड़ी हुई कंपनियों का, Java एक रजिस्टर किया हुआ ट्रेडमार्क है.
आखिरी बार 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```"]]