Skip to content

Instantly share code, notes, and snippets.

@bobbydeveaux
Created March 13, 2014 21:32
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 bobbydeveaux/9537406 to your computer and use it in GitHub Desktop.
Save bobbydeveaux/9537406 to your computer and use it in GitHub Desktop.
JS Bubble Sort
function main() {
for (var c = 0; c < 1000000; c++) {
bubble();
}
}
function bubble() {
var array = [3,4,1,3,5,1,92,2,4124,424,52,12];
for (var i = 0; i < array.length; i++) {
for (var y = 0; y < array.length - 1; y++) {
if (array[y+1] < array[y]) {
var t = array[y];
array[y] = array[y + 1];
array[y + 1] = t;
}
}
}
}
main();
@bobbydeveaux
Copy link
Author

NODE
$ time node bubble.js

real 0m0.484s
real 0m0.489s
real 0m0.491s
real 0m0.489s
real 0m0.496s

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