Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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