Skip to content

Instantly share code, notes, and snippets.

@hiroshi-maybe
Created January 26, 2013 11:09
Show Gist options
  • Save hiroshi-maybe/4641767 to your computer and use it in GitHub Desktop.
Save hiroshi-maybe/4641767 to your computer and use it in GitHub Desktop.
Sleep sort implemented with Javascript.
var sleepSort = function(array){
for (var i=0, length=array.length; i<length; i+=1) {
setTimeout((function(n){
return function(){
console.log(n);
};
})(array[i]), array[i]*100);
}
};
sleepSort([5,1,3,2,1,0,10]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment