Created
May 24, 2012 10:07
-
-
Save thorn/2780613 to your computer and use it in GitHub Desktop.
sorts object by key coffescript
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
sort_obj_by_key = (obj) -> | |
sorted = {} | |
keys = (key for own key, value of obj).sort() | |
sorted[key] = obj[key] for key in keys | |
sorted |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment