Skip to content

Instantly share code, notes, and snippets.

@Oziabr
Last active March 30, 2016 13:47
Show Gist options
  • Save Oziabr/d38f843a6bb6a4ad6f27ecc0325b81cd to your computer and use it in GitHub Desktop.
Save Oziabr/d38f843a6bb6a4ad6f27ecc0325b81cd to your computer and use it in GitHub Desktop.
input = [0,1,2,3,4,5,6,7,8,9]
len = 3
resort = function(input, len) {
count = len
while(count--) {
last = input.length-(len-count)
id = parseInt(Math.random()*last)
el = input[id]
input[id] = input[last]
input[last] = el
}
return input.slice(-len)
}
resort(input, len)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment