Skip to content

Instantly share code, notes, and snippets.

@Archakov06
Last active November 9, 2018 15:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Archakov06/f23c295765ba8fdd0db9629c47fd536d to your computer and use it in GitHub Desktop.
Save Archakov06/f23c295765ba8fdd0db9629c47fd536d to your computer and use it in GitHub Desktop.
ES6 Sort Object
Object.keys(tags)
.sort((a, b) => tags[a] - tags[b])
.reverse()
.map((name, i) => ({ [name]: tags[name] }))
// before: {a: 3, b: 4, c: 2: d: 1}
// after: {b: 4, a: 3, c: 2, d: 1}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment