Skip to content

Instantly share code, notes, and snippets.

@MahmoudAgamy
Last active February 13, 2019 16:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MahmoudAgamy/916291307100ed1e6e575fe9b2d2e037 to your computer and use it in GitHub Desktop.
Save MahmoudAgamy/916291307100ed1e6e575fe9b2d2e037 to your computer and use it in GitHub Desktop.
let obj = { a: 2, b: 4, c: 2, k: 1 }
let sortedKeys = Object.keys(obj).sort((a,b)=>obj[b]-obj[a])
console.log(sortedKeys) // [ 'b', 'a', 'c', 'k' ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment