-
-
Save duncanbeevers/3930701 to your computer and use it in GitHub Desktop.
CoffeeScript Implementation of the Fisher-Yates array sorting algorithm
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
fisherYates = (array) -> | |
cap = array.length | |
for e, i in array | |
j = Math.floor(Math.random() * (cap - i)) + i | |
[ array[i], array[j] ] = [ array[j], e ] unless i == j | |
array |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment