Last active
November 9, 2018 15:03
-
-
Save Archakov06/f23c295765ba8fdd0db9629c47fd536d to your computer and use it in GitHub Desktop.
ES6 Sort Object
This file contains hidden or 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
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