选择排序
const arr = [21, 2, 5, 3, 1, 2, 6, 3, 3]; function select(data) { var index; for (let i = 0; i < data.length - 1; i++) { index = i; for (let m = i; m < data.length; m++) { if (data[index] > data[m]) { index = m; } } let tmp = data[index]; data[index] = data[i]; data[i] = tmp; } return data; } console.log(select(arr));