Skip to content

Instantly share code, notes, and snippets.

@jinnyMcKindy
Created June 29, 2020 20:22
Show Gist options
  • Save jinnyMcKindy/f56792629795cc86ef8ea0d98a6acad4 to your computer and use it in GitHub Desktop.
Save jinnyMcKindy/f56792629795cc86ef8ea0d98a6acad4 to your computer and use it in GitHub Desktop.
buble sort
function bubbleSort(arr) {
arr.forEach((_, i) => {
if(arr[i] > arr[i + 1]) {
let a = arr[i];
let b = arr[i + 1];
arr[i] = b;
arr[i + 1] = a;
}
})
return arr;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment