Skip to content

Instantly share code, notes, and snippets.

@farskid
Created January 29, 2018 22:41
Show Gist options
  • Save farskid/b1c128639cd42e44734282e2d9e3beb2 to your computer and use it in GitHub Desktop.
Save farskid/b1c128639cd42e44734282e2d9e3beb2 to your computer and use it in GitHub Desktop.
Sort object keys alphabetically
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