Skip to content

Instantly share code, notes, and snippets.

@zinevych
Created May 31, 2019 11:43
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 zinevych/288bfa330951d6c8d702da094f1087a9 to your computer and use it in GitHub Desktop.
Save zinevych/288bfa330951d6c8d702da094f1087a9 to your computer and use it in GitHub Desktop.
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