var arr = [21, 434, 11, 333, 75, 39, 90, 234, 66, 85];
for(var i = 0; i < arr.length - 1; ++i) { for(var u = 0; u < arr.length - 1 - i; ++u) { if(arr[u] > arr[u + 1]) { var temp = arr[u + 1]; arr[u + 1] = arr[u]; arr[u] = temp; } }}console.log(arr);
时间: 2024-10-06 08:14:09