Shortest possible code with ES6!
users.sort((a, b) => a.firstname.localeCompare(b.firstname))
String.prototype.localeCompare() basic support is universal!
More Related Contents:
- jQuery .animate function not responding properly
- Why the timer setTimeout returns the first value “2”
- Get all non-unique values (i.e.: duplicate/more than one occurrence) in an array
- How can I add 1 day to current date?
- Assign click handlers in for loop
- Can I apply the required attribute to fields in HTML5?
- How to get first and last day of the current week in JavaScript
- How to override Backbone.sync?
- How can I use goto in Javascript?
- Javascript Audio Play on click
- Mongoose find/update subdocument
- How do I generate sourcemaps when using babel and webpack?
- Load “Vanilla” Javascript Libraries into Node.js
- Case insensitive jQuery attribute selector
- How to know whether refresh button or browser back button is clicked in Firefox [duplicate]
- AJAX request to local file system not working in Chrome? [duplicate]
- ReCaptcha API v2 Styling
- Do I need to hide API key when using google maps js API? If so, how?
- Detecting combination keypresses (Control, Alt, Shift)?
- Declare an empty two-dimensional array in Javascript?
- How to pass parameters to a modal?
- How do I change the ID of a HTML element with JavaScript?
- Debounce function in jQuery
- Is it possible to rename a key in the Firebase Realtime Database?
- Should we use useCallback in every function handler in React Functional Components
- How can I use regex to get all the characters after a specific character, e.g. comma (“,”)
- How to set the loudness of HTML5 audio?
- How to develop Chrome extension for Gmail?
- How do I find the DOM node that is at a given (X,Y) position? (Hit test)
- Get height of iframe with external URL