Skip to content

Instantly share code, notes, and snippets.

@MahmoudAgamy
Created February 13, 2019 19:44
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/f8c5c41683bd7563e92849fdedbc17fd to your computer and use it in GitHub Desktop.
Save MahmoudAgamy/f8c5c41683bd7563e92849fdedbc17fd 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