JavaScript localeCompare
function returns a number and tell whether string comes before, after or is the same as the compareString
in sort order and this returns one of three values: -1 if the reference string is sorted before the 2nd string 0 if the two strings are equal 1 if the reference string is sorted after the 2nd string See the code snippet: