Skip to content

Instantly share code, notes, and snippets.

@PantherHawk
Last active March 1, 2017 03:43
Show Gist options
  • Save PantherHawk/3e376d00b559582ada2612df1ef99c49 to your computer and use it in GitHub Desktop.
Save PantherHawk/3e376d00b559582ada2612df1ef99c49 to your computer and use it in GitHub Desktop.
function bubbleSort(array) {
var i, j;
for (i = array.length - 1; i >= 0; i--) {
for (j = 0; j <= i; j++) {
if (array[j + 1] < array[j]) {
var temp = array[j];
array[j] = array[j + 1];
array[j + 1] = temp;
}
}
}
return array;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment