Answers for "how to sort sentences in js"

10

js sort alphabetically

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

javascript hot to sort letters

const sort = str => str.split('').sort((a, b) => a.localeCompare(b)).join('');

// Example:
sort('eat'); 
// Output:
// 'aet'
Posted by: Guest on October-25-2021
3

js sort alphabetically

users.sort(function(a, b){
    if(a.firstname < b.firstname) { return -1; }
    if(a.firstname > b.firstname) { return 1; }
    return 0;
})
Posted by: Guest on July-13-2021

Code answers related to "how to sort sentences in js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language