Home:ALL Converter>Lexicographically compare strings in google apps script

Lexicographically compare strings in google apps script

Ask Time:2020-02-11T17:57:30         Author:Adrian M

Json Formatter

Trying to compare two strings lexicographically in google apps scripts.

str.compareTo() doesnt work... Is there another way to do this? I've searched through many answers on stack and on the google apps script docs couldn't find a solution.

Author:Adrian M,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/60166190/lexicographically-compare-strings-in-google-apps-script
Iamblichus :

\nYou can use localeCompare:\n\n\na.localeCompare(b)\n\n\nThis will return 1 or -1 depending on which string is lexicographically greater.\n\n\nDirectly comparing both strings would also work:\n\n\na > b\n\n\nThis will return true or false.\n\nReference:\n\n\nString.prototype.localeCompare()\n",
2020-02-11T11:59:42
yy