Skip to content

Instantly share code, notes, and snippets.

@kaz-a
Created November 19, 2017 19:25
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 kaz-a/6c6fb2f1d0447eb5f5ab9ad203ea0eb8 to your computer and use it in GitHub Desktop.
Save kaz-a/6c6fb2f1d0447eb5f5ab9ad203ea0eb8 to your computer and use it in GitHub Desktop.
Bubble sort algorithm
const bubbleSort = arr => {
for (let i=arr.length-1; i>=0; i--){
for(let j=1; j<=i; j++){
if(arr[j-1]>arr[j]){
var temp = arr[j-1];
arr[j-1] = arr[j];
arr[j] = temp;
}
}
}
return arr;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment