冒泡排序
function sort(arr){
for(var i=0;i<arr.length;i++){
for(var j=0;j<arr.length-i-1;j++){
if(arr[j]>arr[j+1]){
var swap=arr[j];
arr[j]=arr[j+1];
arr[j+1]=swap;
}
}
}
}
var arr=[3,1,5,7,2,4,9,6,10,8];
sort(arr);
排重
var arr=[5,4,26,9,4,8,5,14,26];
var newArr=[];
for (var i = 0; i < arr.length; i++) {
if(newArr.indexOf(arr[i])==-1){
newArr.push(arr[i])
}
};
console.log(newArr);