1 for(var i = 0; i < arr.length; i++) { 2 for(var j = i+1; j < arr.length; j++) { 3 if(arr[i] > arr[j]) { 4 var temp; 5 temp = arr[i]; 6 arr[i] = arr[j]; 7 arr[j] = temp; 8 } 9 } 10 } 11 12 for(var x in arr){ 13 alert(arr[x]); 14 }
时间: 2024-10-17 10:04:51