Last active
October 2, 2020 14:40
-
-
Save esutton/73f00528ee4e4fcc481924ac92207c16 to your computer and use it in GitHub Desktop.
ES6 sort object array by key name
This file contains hidden or 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
arrayList.sort((a, b) => { | |
const textA = a.name.toUpperCase(); | |
const textB = b.name.toUpperCase(); | |
return (textA < textB) ? -1 : (textA > textB) ? 1 : 0; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment