Created
June 29, 2020 20:22
-
-
Save jinnyMcKindy/f56792629795cc86ef8ea0d98a6acad4 to your computer and use it in GitHub Desktop.
buble sort
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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