Skip to content

Instantly share code, notes, and snippets.

@cocodrips
Created June 17, 2013 20:27
Show Gist options
  • Save cocodrips/5800041 to your computer and use it in GitHub Desktop.
Save cocodrips/5800041 to your computer and use it in GitHub Desktop.
CoffeeScriptでshuffle
shuffle = (array) ->
for i in [array.length-1..0]
j = Math.floor( Math.random() * (i + 1) )
[array[i], array[j]] = [array[j], array[i]]
return array
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment