Skip to content

Instantly share code, notes, and snippets.

@aemkei
Created February 9, 2009 09:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aemkei/60729 to your computer and use it in GitHub Desktop.
Save aemkei/60729 to your computer and use it in GitHub Desktop.
function bubbleSort(array, onComplete){
var pos = 0;
(function(){
var j, value;
for (j=array.length; j > pos; j--){
if (array[j] < array[j-1]){
value = data[j];
data[j] = data[j-1];
data[j-1] = value;
}
}
pos++;
if (pos < array.length){
setTimeout(arguments.callee,10);
} else {
onComplete();
}
})();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment