Skip to content

Commit abcfdf7

Browse files
committed
solve : bubble sort 구현
1 parent f459075 commit abcfdf7

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

CS/Sort/do02reen24/bubbleSort.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
function bubbleSort(arr) {
2+
for (let i = 0; i < arr.length - 1; i++) {
3+
for (let j = 0; j < arr.length - 1 - i; j++) {
4+
if (arr[j] > arr[j + 1]) {
5+
let temp = arr[j];
6+
arr[j] = arr[j + 1];
7+
arr[j + 1] = temp;
8+
}
9+
}
10+
}
11+
return arr;
12+
}

0 commit comments

Comments
 (0)