Skip to content

Instantly share code, notes, and snippets.

@ox
Created August 14, 2013 06:02
Show Gist options
  • Save ox/6228399 to your computer and use it in GitHub Desktop.
Save ox/6228399 to your computer and use it in GitHub Desktop.
var k = [1,4,2,5,3,2,2,5,7,8,8,5,3,4,4,4,2,1]
function bundle(arr) {
var t = {}
arr.map(function (x) {
if (!t[x]) t[x] = []
t[x].push(x)
})
return Object.keys(t).reduce(function (memo, x) { return memo.concat([t[x]])}, [])
}
console.log(bundle(k))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment