Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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
Comment

js how to sort strings in array

let fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.sort()
console.log(fruits)
// [ 'Apple', 'Banana', 'Mango', 'Orange' ]
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript round off 
Javascript :: how to link js and a html file in vscode 
Javascript :: onsubmit in reactjs 
Javascript :: callback hell javascript 
Javascript :: how to remove particular value in dictionary in nodehs 
Javascript :: javascript filter array of objects by array 
Javascript :: looping queryselectorall 
Javascript :: create react expo 
Javascript :: js encryption 
Javascript :: javascript multiline script 
Javascript :: input two decimal places javascript 
Javascript :: react conditional array item 
Javascript :: javascript array group by id 
Javascript :: empty input field on click 
Javascript :: javascript swap variables 
Javascript :: discord.js embed timestamp 
Javascript :: set datatable with jquery success return value 
Javascript :: convert date dd/mm/yyyy to date object js 
Javascript :: how to flat an array in javascript iteratively 
Javascript :: TypeError: Class constructor Model cannot be invoked without 
Javascript :: react-hook-form file validation 
Javascript :: react dynamic import 
Javascript :: import card content material ui 
Javascript :: foreach 
Javascript :: jsx style styling 
Javascript :: match city regex 
Javascript :: eventemitter in angular 
Javascript :: javascript particles js not working 
Javascript :: remove value from input jquery 
Javascript :: redux dev tool 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =