javascript string array 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é']var items = ['réservé', 'premier', 'communiqué', 'café', 'adieu', 'éclair'];
items.sort((a, b) =>
a.localeCompare(b)//using String.prototype.localCompare()
);
Also in JavaScript:
- how to add a picker in expo
- javascript check if text is overflowing
- jquery enable textbox
- redirect script javascript
- laravel query json
- legend on click use default chartjs
- && in react jsx
- how to code javascript
- how to use fa-icon in angular
- combotree grid jquery
- create nodejs new object
- how to test useeffect with enzyme
- jquery check input is disable
- javascript number if .00 truncate
- mutable array methods in javascript
- how to solve Could not write JSON: Infinite recursion (StackOverflowError)
- documenting functions javascript
- capitalise first letter js
- get each primary colour and add into an array javascript
- angular mouseenter
- add element to array javascript
- how to stringify json in js
- How to Set focus to first text input in a bootstrap modal after shown
- Material-ui alarm icon