project bootstrap

This commit is contained in:
2023-11-25 18:12:47 -05:00
parent 5cd875ae80
commit 6ef22d88f9
39139 changed files with 4944609 additions and 2 deletions
+20
View File
@@ -0,0 +1,20 @@
export function bubbleSort (list, comparator) {
let upperIndex = list.length - 1;
while (upperIndex > 0) {
let swapIndex = 0;
for (let i = 0; i < upperIndex; i += 1) {
if (comparator(list[i], list[i + 1]) > 0) {
const temp = list[i + 1];
list[i + 1] = list[i];
list[i] = temp;
swapIndex = i;
}
}
upperIndex = swapIndex;
}
return list;
}