1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
let arr = [2, 6, 1, 77, 0, 52, 10, 25, 7, 3]
for (let i = 0; i < arr.length - 1; i++) {
for (let j = 0; j < arr.length - i - 1; j++) {
if (arr[j] > arr[j + 1]) {
let tmp = arr[j + 1]
tmp = arr[j + 1]
arr[j + 1] = arr[j]
arr[j] = tmp
}
}
}
console.log(arr)
|