Skip to content

Instantly share code, notes, and snippets.

@jordanrios94
Last active February 9, 2023 09:54
Show Gist options
  • Save jordanrios94/c27f55b3ddbe346fcdf724dc0f4c8f5c to your computer and use it in GitHub Desktop.
Save jordanrios94/c27f55b3ddbe346fcdf724dc0f4c8f5c to your computer and use it in GitHub Desktop.
Sorting Algorithms
function bubbleSort(arr) {
for (let i = 0; i < arr.length; i++) {
for (let j = 0; j < (arr.length - i - 1); j++) {
if (arr[j] > arr[j+1]) {
const lesser = arr[j+1];
arr[j+1] = arr[j];
arr[j] = lesser;
}
}
}
return arr;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment