Demo showing the use of the compare method

The compare method is used by Collator, both for sorting (used in this example), and search.

by David Storey

JavaScript

var letters = ["b", "a", "c"],
    collator = new Intl.Collator("en");

console.log(letters.sort(collator.compare)); // ["a", "b", "c"]