js 冒泡排序
var arr = []; for(var i=0; i<100000; i++){ arr.push(parseInt(Math.random()*100)) }; var t1 = Date.now(); for(var j=arr.length; j>0; j--){ for(var k = 0; k<j; k++){ if(arr[k]>arr[k+1]){ var t = arr[k]; arr[k] = arr[k+1]; arr[k+1] = t; }; }; }; var t = new Date(Date.now() - t1).getSeconds(); // 30 console.log(arr,'\n给一万个随机数字升序排列一共花费',t,'秒。');