Skip to content

Commit ecb2833

Browse files
authored
JavaScript
1 parent 7d9a1a0 commit ecb2833

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Selection Sort/selection_sort.js

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

0 commit comments

Comments
 (0)