Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tommylinks/8c3641b1873a9a05b9b1e71e15027593 to your computer and use it in GitHub Desktop.
Save tommylinks/8c3641b1873a9a05b9b1e71e15027593 to your computer and use it in GitHub Desktop.
Sort array by firstname (alphabetically) in Javascript
const users = ["c", "a", "b"]
users.sort((a, b) => a.localeCompare(b)) // ["a", "b", "c"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment