复制代码代码如下所示:
无功listinfos =新的数组();
listinfos { 0 } =新的数组();
listinfos { 0 } { 0 } = { 'name':
推荐1页,'daycount:666、'avgtime:29872、'errcount:180663、'errorrate:'2873 %,'daysystemerrorcount:0、'daysystemrerrorrate:0 % }。
listinfos { 0 } { 1 } = { 'name':推荐2页,'daycount:593896、'avgtime:24946、'errcount:222、'errorrate:2 %,'daysystemerrorcount:0、'daysystemrerrorrate:0 % }。
listinfos { 0 } { 2 } = { 'name':推荐3页,'daycount:956、'avgtime:27957、'errcount:111、'errorrate:10 %,'daysystemerrorcount:0、'daysystemrerrorrate:0 % }。
listinfos { 1 } =新的数组();
listinfos { 1 } { 0 } = { 'name':推荐4页,'daycount:666、'avgtime:116、'errcount:180663、'errorrate:'2873 %,'daysystemerrorcount:0、'daysystemrerrorrate:0 % }。
listinfos { 1 } { 1 } = { 'name':推荐5页,'daycount:11、'avgtime:222、'errcount:222、'errorrate:2 %,'daysystemerrorcount:0、'daysystemrerrorrate:0 % }。
listinfos { 1 } { 2 } = { 'name':推荐6页,'daycount:956、'avgtime:956、'errcount:111、'errorrate:10 %,'daysystemerrorcount:0、'daysystemrerrorrate:0 % }。
功能datedesc(listinfos、场){
对于(var i = 0;i < listinfos.length;i++){
对于(var j = i + 1;J < listinfos.length;j++){
如果(iscommapercent(listinfos {我} {场})< iscommapercent(listinfos { } { } J场)){
无功arraytemp =新的数组();
arraytemp = listinfos {我};
我listinfos { } = { } listinfos {J}.;
listinfos { } = arraytemp {J}.;
}
}
}
返回listinfos;
}
功能dataasc(listinfos、场){
对于(var i = 0;i < listinfos.length;i++){
对于(var j = i + 1;J < listinfos.length;j++){
如果(iscommapercent(listinfos {我} {场})> iscommapercent(listinfos { } { } J场)){
无功arraytemp =新的数组();
arraytemp = listinfos {我};
我listinfos { } = { } listinfos {J}.;
listinfos { } = arraytemp {J}.;
}
}
}
返回listinfos;
}
功能iscommapercent(值){
无功valuefloat;
价值= value.tolocalestring();
valuefloat =(value.indexof(',')> 0)value.split(',')。加入():价值;
valuefloat =(valuefloat.indexof(%)> valuefloat.substr parseFloat(0)(0,valuefloat.indexof(%))):parseFloat(valuefloat);
返回valuefloat;
}
功能sortoperation(sortinfos,字段,
排序){
无功listinfos =新的数组();
如果(排序= = 'desc){
对于(var i = 0;i < sortinfos.length;i++){
我listinfos { } = datedesc(sortinfos {我},场);
}
} else if(排序= = 'asc){
对于(var i = 0;i < sortinfos.length;i++){
我listinfos { } = dataasc(sortinfos {我},场);
}
其他{ }
警报(手术
错误);
返回false;
}
无功tablestrlist =;
对于(var i = 0;i < listinfos.length;i++){
无功tablestr = 'program;
tablestr + =;
tablestr + = 'program命名日访问(次)平均响应时间(美国)错误数(时间);
tablestr + =错误率(%)
系统错误数(时间)的系统误差率(%);
对于(var j = 0;J < listinfos {我}。长度;j++){
tablestr + =;
tablestr + =+ listinfos {我} { } { },'name' + ';
tablestr + =+ listinfos {我} { } { },'daycount ' + ';
tablestr + =+ listinfos {我} { } { },'avgtime ' + ';
tablestr + =+ listinfos {我} { } { },'errcount ' + ';
tablestr + =+ listinfos {我} { } { },'errorrate ' + ';
tablestr + =+ listinfos {我} { } { },'daysystemerrorcount ' + ';
tablestr + =+ listinfos {我} { } { },'daysystemrerrorrate ' + ';
tablestr + =;
}
tablestr + =;
tablestrlist = tablestr
}
document.getelementbyid(HTML).innerHTML = tablestrlist;
}
sortoperation(listinfos,'daycount ','asc)