compare (I18n - JavaScript)

Compares two strings lexicographically, following the locale comparison rules.

The comparison is done by using a Java Collator object. If the locale is null, or if there is no Collator implementation for this locale, the comparison is done by using the XSP server locale. If there is no collator for the XSP server locale, the comparison is done by using 'compareTo' method in Java String class. A null pointer exception may be thrown if one of the strings is null.
Compares two strings lexicographically, by using 'compareTo' method in Java String class. A null pointer exception may be thrown if one of the argument is null. Read also the documentation of 'compare(String, String, Locale)' method.

Defined in

I18n

Syntax

compare(s1:string, s2:string, loc:Locale) : int

compare(s1:string, s2:string) : int