Last active
January 3, 2016 22:39
-
-
Save mattd/8529838 to your computer and use it in GitHub Desktop.
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
var obj = { | |
blake: 20, | |
andrew: 10, | |
matt: 45 | |
}; | |
var annotated = _.map(obj, function (value, key) { | |
return {key: key, value: value}; | |
}); | |
var names = _.pluck(_.sortBy(annotated, 'value'), 'key'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@kaw2k - Niiiice. That's exactly the combo I'd figured I'd missed. I might argue that the sortBy piece is easier to reason about when you're sorting by a keyname - like value. But yours is definitely more compact.
And that curried version is tasty.
(Also, I think you meant
_.values()
.)