Horje
js sort string array Code Example
javascript sort alphabetically
var items = ['réservé', 'premier', 'communiqué', 'café', 'adieu', 'éclair'];
items.sort(function (a, b) {
  return a.localeCompare(b); //using String.prototype.localCompare()
});

// items is ['adieu', 'café', 'communiqué', 'éclair', 'premier', 'réservé']
js sort string array
const sort = (arr) => arr.slice().sort(); // default sort
const sort = (arr) => arr.slice().sort((a, b) => a - b); // simple sort
const sort = (arr) => arr.slice().sort((a, b) => a.localeCompare(b, 'en', { sensitivity: 'base' })); // language-specific sort
js sort string array
users.sort((a, b) => a.firstname.localeCompare(b.firstname))
array sort by alphabetical javascript
users.sort((a, b) => a.firstname.localeCompare(b.firstname))
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()
);
javascript sort array strings alphabetically
//sort array alphabetically
objArray.sort(function(a, b) {
   return a.localeCompare(b);
});




Javascript

Related
mute video  javascript Code Example mute video javascript Code Example
async await anonymous function Code Example async await anonymous function Code Example
javascript add spaces to string Code Example javascript add spaces to string Code Example
get the element the cursor hovering over Code Example get the element the cursor hovering over Code Example
how to clean modal on js in event hide Code Example how to clean modal on js in event hide Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8