Last active
March 30, 2016 13:47
-
-
Save Oziabr/d38f843a6bb6a4ad6f27ecc0325b81cd to your computer and use it in GitHub Desktop.
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
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