<script>
var array=[2,4,1,3,5];
for(var i=0;i<array.length-1;i++)
{
for(var j=0;j<array.length-1-i;j++)
{
if(array[j]>array[j+1])
{
temp=array[j];
array[j]=array[j+1];
array[j+1]=temp;
}
}
}
console.log(array);
</script>
JavaScript笔记8_数组冒泡排序
最新推荐文章于 2021-03-19 18:59:10 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)