var str = [4,3,52,2,5,1,8];
for (var i = 0; i <= str.length- 1; i++ ) {
for (var j = 0; j <= str.length - i -1; j++) {
if (str[j + 1] < str[j]) {
var num = str[j];
str[j] = str[j+1];
str[j+1] = num;
}
}
}
console.log(str);
08-02
871
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
10-17
928
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)