Created
February 9, 2009 09:37
-
-
Save aemkei/60729 to your computer and use it in GitHub Desktop.
This file contains 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
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