15.5.4.9 String.prototype.localeCompare(that)

2010-07-10

number String.prototype.localeCompare(that)

Returns a number (not NaN) that reflects the result of comparing this to that using the locale (set of characters, sort order of your language) of your computer.

No explicit algorithm is given.

The this value and that are converted to a string.

It uses localeCompare, which should behave as consistent as the comparison function defined in 15.4.4.11 but which is not explicitly defined.

If this and that represent the same string, 0 or -0 should be returned.

The spec notes that this function cannot be used with Array.prototype.sort because it only takes one argument.

It also notes that the second parameter might be used in a future specification and warns not to use it.