Skip to content

Instantly share code, notes, and snippets.

@ringmaster
Created March 28, 2014 18:15
Show Gist options
  • Save ringmaster/9839375 to your computer and use it in GitHub Desktop.
Save ringmaster/9839375 to your computer and use it in GitHub Desktop.
groupZeros = function (ar) {
for(var i = ar.length - 1; i > 0; i--) {
if(ar[i] == 0) {
for(var z = 0; z < i - 1; z++) {
if(ar[z] == 0) {
ar.splice(i, 1);
ar.splice(z, 0, 0);
z = i;
}
}
}
}
return ar;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment