Skip to content

Instantly share code, notes, and snippets.

@eengineergz
Created February 27, 2021 05:02
Show Gist options
  • Save eengineergz/80934783c628c70ac2a5a48119a82d54 to your computer and use it in GitHub Desktop.
Save eengineergz/80934783c628c70ac2a5a48119a82d54 to your computer and use it in GitHub Desktop.
function bubbleSort(items) {
let length = items.length;
for (let i = 0; i < length; i++) {
for (let j = 0; j < length - i - 1; j++) {
if (items[j] > items[j + 1]) {
let tmp = items[j];
items[j] = items[j + 1];
items[j + 1] = tmp;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment