Created
May 31, 2019 11:43
-
-
Save zinevych/288bfa330951d6c8d702da094f1087a9 to your computer and use it in GitHub Desktop.
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
const bubbleSort = (inputArr) => { | |
let length = inputArr.length; | |
for (let i = 0; i < length; i++) { | |
for (let j = 0; j < length; j++) { | |
if (inputArr[j] > inputArr[j + 1]) { | |
let tmp = inputArr[j]; | |
inputArr[j] = inputArr[j + 1]; | |
inputArr[j + 1] = tmp; | |
} | |
} | |
} | |
return inputArr; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment