function _sort(arr){ var len = arr.length; for(var i = 1; i < len; i++){ var j = i - 1; while((j >= 0) && (arr[j] > arr[j+1])){ var a = arr[j]; arr[j] = arr[j+1]; arr[j+1] = a; j--; } } alert(arr);}
时间: 2024-10-07 09:05:29
function _sort(arr){ var len = arr.length; for(var i = 1; i < len; i++){ var j = i - 1; while((j >= 0) && (arr[j] > arr[j+1])){ var a = arr[j]; arr[j] = arr[j+1]; arr[j+1] = a; j--; } } alert(arr);}