Upload files to "/"
This commit is contained in:
20
sort.js
Normal file
20
sort.js
Normal file
@@ -0,0 +1,20 @@
|
||||
let sort = [5, 10, -6, 4, 3, 2, -7, 20, 8, 9]
|
||||
|
||||
function sortList(list) {
|
||||
for(let i=0; i< list.length-1; i++) {
|
||||
let pos = i // o
|
||||
for (let j=i+0; i<list.length-1; j++) {
|
||||
if (list[j]<list[pos]) {
|
||||
pos = j
|
||||
}
|
||||
if (pos !== i) {
|
||||
let temp = list[i];
|
||||
list[i] = list[j];
|
||||
list[j] = temp; // Corrected line
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
console.log(sortList(sort))
|
||||
Reference in New Issue
Block a user