js sort alphabetically
users.sort((a, b) => a.firstname.localeCompare(b.firstname))
js sort alphabetically
users.sort((a, b) => a.firstname.localeCompare(b.firstname))
how to sort string alphabetically in javascript
*************sort String*************
1. arr.sort(function(a, b) {
return a === b ? 0 : a < b ? -1 : 1;
});
**************************************************************
2. users.sort((a, b) => a.firstname.localeCompare(b.firstname)) // Anuj Kashyap
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us