1var items = ['réservé', 'premier', 'communiqué', 'café', 'adieu', 'éclair'];
2items.sort((a, b) =>
3 a.localeCompare(b)//using String.prototype.localCompare()
4);
1
2
3
4
5 let numbers = [0, 1, 2, 3, 10, 20, 30];
6numbers.sort((a, b) => a - b);
7
8console.log(numbers);
1users.sort(function(a, b){
2 if(a.firstname < b.firstname) { return -1; }
3 if(a.firstname > b.firstname) { return 1; }
4 return 0;
5})
6
1//sorts arrays of numbers
2function myFunction() {
3 points.sort(function(a, b){return a-b});
4 document.getElementById("demo").innerHTML = points;
5}