var arr = [3, 2, 2, 34, 6, 10, 10, 10];
var num;
for (var i = 0; i < arr.length; i++) {
for (var j = i + 1; j < arr.length; j++) {
if (arr[i] == arr[j]) {
arr.splice(j, 1);
j--;
}
}
}
for (var i = 0; i < arr.length; i++) {
for (var j = 0; j < arr.length + 1; j++) {
if (arr[j] > arr[j + 1]) {
num = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = num;
}
}
}
console.log(arr);
数组去重排序
最新推荐文章于 2024-09-01 00:14:28 发布