Skip to content

Instantly share code, notes, and snippets.

@rambattu
Last active November 7, 2017 06:35
Show Gist options
  • Save rambattu/81a46d43080ce4316d91b5ba6be1c84b to your computer and use it in GitHub Desktop.
Save rambattu/81a46d43080ce4316d91b5ba6be1c84b to your computer and use it in GitHub Desktop.
Random arrangement of an array
values = [1,1,2,2,5,3,3,4,4]
op = [-1,0,1]
values.sort(function(a,b){ return op[Math.floor(Math.random()*op.length)] })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment