Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@madrobby
Forked from remy/gist:330584
Created March 16, 2010 08:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save madrobby/333764 to your computer and use it in GitHub Desktop.
Save madrobby/333764 to your computer and use it in GitHub Desktop.
// pure JS
function shuffle(array) {
return array.sort(function(){
return .5 - Math.random();
});
}
// with Prototype.js you can do
function shuffle(array){
return array.sortBy(Math.random);
}
@eccajune
Copy link

Where do i insert this piece of code? :) i can't seem to make it work.

I have 11 songs.
Do i need to edit the code:

// pure JS
function shuffle(array) {
return array.sort(function(){
return .11 - Math.random();
});
}

I putted it below the head in my html file, under the playlist.

@eccajune
Copy link

in jplayer of course :)

@ipruthi
Copy link

ipruthi commented Feb 4, 2013

eccajune: Mind being more specific? I'm looking to shuffle a jPlayer Video Playlist but I don't know at what hook to insert this code. Thank you for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment