Created
January 29, 2018 22:41
-
-
Save farskid/b1c128639cd42e44734282e2d9e3beb2 to your computer and use it in GitHub Desktop.
Sort object keys 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
function sortObjKeysAlphabetically(obj) { | |
return Object.keys(obj).sort((a,b) => a > b).reduce((result, key) => { | |
result[key] = obj[key]; | |
return result; | |
}, {}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment