1.for循环排序
let arr=[1,2,343,33,2,1,56,3];
for(i=0;i<arr.length;i++){
for(j=i+1;j<arr.length;j++){
if(arr[i]>arr[j]){
let temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
}
}
}
console.log(arr);
2.sort
<script type="text/javascript">
function sortNumber(a,b)
{
return a - b
}
var arr = [1,1,33,22,4,1,5,6]
document.write(arr + "<br />")
document.write(arr.sort(sortNumber)
) </script>