Created
April 30, 2013 04:43
-
-
Save Calvein/5486620 to your computer and use it in GitHub Desktop.
Invert array/object data
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
headings = [] | |
_.each o.groups, (group, label) => | |
headings.push(label) | |
groups = {} | |
_.each o.headings, (heading) => | |
groups[heading] = values: [] | |
_.each headings, (heading, i) => | |
_.each o.groups[Object.keys(o.groups)[i]].values, (val, j) => | |
groups[Object.keys(groups)[j]].values.push(val) | |
o.headings = headings | |
o.groups = groups | |
copy JSON.stringify o |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment