Answers for "sort function for strings of array in js"

10

javascript order by string array

users.sort((a, b) => a.firstname.localeCompare(b.firstname))
Posted by: Guest on October-19-2020
1

js how to sort strings in array

let fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.sort()
console.log(fruits)
// [ 'Apple', 'Banana', 'Mango', 'Orange' ]
Posted by: Guest on December-28-2021

Code answers related to "sort function for strings of array in js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language