javascript表内容排序简单操作示例代码

javascript表内容排序简单操作示例代码
复制代码代码如下所示:
无功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)

免责声明:本网信息来自于互联网,目的在于传递更多信息,并不代表本网赞同其观点。其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,并请自行核实相关内容。本站不承担此类作品侵权行为的直接责任及连带责任。如若本网有任何内容侵犯您的权益,请及时联系我们,本站将会在24小时内处理完毕。
相关文章
返回顶部