javascript array sort alphabetically function code example
Example 1: javascript string array sort alphabetically
var items = ['réservé', 'premier', 'communiqué', 'café', 'adieu', 'éclair'];
items.sort((a, b) =>
a.localeCompare(b)//using String.prototype.localCompare()
);
Example 2: js sort asendenet
var points = [40, 100, 1, 5, 25, 10];
points.sort(function(a, b){return a-b});