Skip to content

Instantly share code, notes, and snippets.

@MiCkEyZzZ
Created June 17, 2021 22:18
Show Gist options
  • Save MiCkEyZzZ/42ee48d275ee042d94516edcc60d798c to your computer and use it in GitHub Desktop.
Save MiCkEyZzZ/42ee48d275ee042d94516edcc60d798c to your computer and use it in GitHub Desktop.
Bubble sort
function bubbleSearch (array) {
for (let i = 0; i < array.length; i++) {
for (let j = 0; j < array.length; j++) {
if (array[j + 1] < array[j]) {
let tmp = array[j]
array[j] = array[j + 1]
array[j + 1] = tmp
}
}
}
return array
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment