Created
June 7, 2022 14:16
-
-
Save mhaecal/ced1b1c2a665ea85c87f8f9f389c6f2e to your computer and use it in GitHub Desktop.
Sort JavaScript Array of Objects Numerically / Alphabetically
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
items.sort(function(a, b) { | |
return a.id - b.id || a.name.localeCompare(b.name); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://stackoverflow.com/questions/12900058/how-can-i-sort-a-javascript-array-of-objects-numerically-and-then-alphabetically