let data = [3,44,38,5,47,15,36,26,27,2,46,26,50,19,48];
//冒泡排序算法
function bubble(arr){
let copy = [...arr];
let n = copy.length-1;
for(let i=0;i<n;i++){
for(let j=0;j<n-i;j++){
if(copy[j]>copy[j+1]){
[copy[j],copy[j+1]] = [copy[j+1],copy[j]];
}
}
}
return copy;
}
//选择排序算法
function selection(arr){
let copy = [...arr];
let n = copy.length-1;
for(let i=0;i<n;i++){
for(let j=i+1;j<n+1;j++){
if(copy[j]<copy[i]){
[copy[i],copy[j]] = [copy[j],copy[i]];
}
}
}
}
console.log(bubble(data));
console.log(selection(data));
console