Created
November 8, 2014 19:26
-
-
Save tanshio/361d75c97b91bd1acdf9 to your computer and use it in GitHub Desktop.
arrRandom.js
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
| var n = a.length; | |
| for(var i = n - 1; i > 0; i--) { | |
| var j = Math.floor(Math.random() * (i + 1)); | |
| var tmp = a[i]; | |
| a[i] = a[j]; | |
| a[j] = tmp; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment