冒泡排序
function a(arr) {
for (var i = 0; i < arr.length - 1; i++) {
for (var p = 0; p < arr.length - 1 - i; p++) {
if (arr[p] > arr[p + 1]) {
var l = arr[p];
arr[p] = arr[p + 1];
arr[p + 1] = l;
}
}
}
return arr;
}
var arr = [1, 2, 50, 40, 60, 70, 40, 20, 11];
console.log(a(arr));