list内层的list的字段的排序
Posted jishuzhainv
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了list内层的list的字段的排序相关的知识,希望对你有一定的参考价值。
<script>
var subjectBaseId = 1;
var list = [{"studentId":1250308,"clzssId":32553,"sex":"女","studentNo":"Y2016101947","interimStatus":1,"yswScoreRank":"69.0/9/19","totalScoreRank":"204.0/1/1","studentName":"胡小辉","clzssName":"2班","yswScore":69.0,"totalScore":204.0,"yswClzssRank":9,"totalClzssRank":1,"yswGradeRank":19,"totalGradeRank":1,"yswSubjectList":[{"score":69.0,"gradeRank":19,"clzssRank":9,"subjectBaseId":1,"subjectName":"数学"}],"extraSubjectList":[{"score":135.0,"gradeRank":1,"clzssRank":1,"subjectBaseId":4,"subjectName":"物理"}]},{"studentId":1250315,"clzssId":32552,"sex":"男","studentNo":"Y2016101954","interimStatus":2,"yswScoreRank":"95.0/1/1","totalScoreRank":"169.0/1/2","studentName":"马振东","clzssName":"1班","yswScore":95.0,"totalScore":169.0,"yswClzssRank":1,"totalClzssRank":1,"yswGradeRank":1,"totalGradeRank":2,"yswSubjectList":[{"score":95.0,"gradeRank":1,"clzssRank":1,"subjectBaseId":1,"subjectName":"数学"}],"extraSubjectList":[{"score":74.0,"gradeRank":4,"clzssRank":1,"subjectBaseId":4,"subjectName":"物理"}]},{"studentId":1250311,"clzssId":32553,"sex":"女","studentNo":"Y2016101950","interimStatus":1,"yswScoreRank":"90.0/1/2","totalScoreRank":"164.0/2/3","studentName":"马建","clzssName":"2班","yswScore":90.0,"totalScore":164.0,"yswClzssRank":1,"totalClzssRank":2,"yswGradeRank":2,"totalGradeRank":3,"yswSubjectList":[{"score":90.0,"gradeRank":3,"clzssRank":2,"subjectBaseId":1,"subjectName":"数学"}],"extraSubjectList":[{"score":74.0,"gradeRank":4,"clzssRank":4,"subjectBaseId":4,"subjectName":"物理"}]},{"studentId":1250319,"clzssId":32553,"sex":"女","studentNo":"Y2016101958","interimStatus":1,"yswScoreRank":"84.0/4/8","totalScoreRank":"164.0/2/3","studentName":"王生琼","clzssName":"2班","yswScore":84.0,"totalScore":164.0,"yswClzssRank":4,"totalClzssRank":2,"yswGradeRank":8,"totalGradeRank":3,"yswSubjectList":[{"score":84.0,"gradeRank":8,"clzssRank":4,"subjectBaseId":1,"subjectName":"数学"}],"extraSubjectList":[{"score":80.0,"gradeRank":3,"clzssRank":3,"subjectBaseId":4,"subjectName":"物理"}]},{"studentId":1250323,"clzssId":32553,"sex":"女","studentNo":"Y2016101962","interimStatus":1,"yswScoreRank":"95.0/1/2","totalScoreRank":"164.0/2/3","studentName":"常大安","clzssName":"2班","yswScore":95.0,"totalScore":164.0,"yswClzssRank":1,"totalClzssRank":2,"yswGradeRank":2,"totalGradeRank":3,"yswSubjectList":[{"score":95.0,"gradeRank":1,"clzssRank":1,"subjectBaseId":1,"subjectName":"数学"}],"extraSubjectList":[{"score":69.0,"gradeRank":10,"clzssRank":7,"subjectBaseId":4,"subjectName":"物理"}]},{"studentId":1250325,"clzssId":32553,"sex":"男","studentNo":"Y2016101964","interimStatus":1,"yswScoreRank":"86.0/3/5","totalScoreRank":"152.0/5/6","studentName":"马峰超","clzssName":"2班","yswScore":86.0,"totalScore":152.0,"yswClzssRank":3,"totalClzssRank":5,"yswGradeRank":5,"totalGradeRank":6,"yswSubjectList":[{"score":86.0,"gradeRank":5,"clzssRank":3,"subjectBaseId":1,"subjectName":"数学"}],"extraSubjectList":[{"score":66.0,"gradeRank":14,"clzssRank":9,"subjectBaseId":4,"subjectName":"物理"}]},{"studentId":1250317,"clzssId":32554,"sex":"男","studentNo":"Y2016101956","interimStatus":1,"yswScoreRank":"82.0/4/10","totalScoreRank":"152.0/1/6","studentName":"韩天福","clzssName":"3班","yswScore":82.0,"totalScore":152.0,"yswClzssRank":4,"totalClzssRank":1,"yswGradeRank":10,"totalGradeRank":6,"yswSubjectList":[{"score":82.0,"gradeRank":10,"clzssRank":4,"subjectBaseId":1,"subjectName":"数学"}],"extraSubjectList":[{"score":70.0,"gradeRank":8,"clzssRank":1,"subjectBaseId":4,"subjectName":"物理"}]},{"studentId":1250330,"clzssId":32554,"sex":"男","studentNo":"Y2016101969","interimStatus":1,"yswScoreRank":"85.0/2/7","totalScoreRank":"150.0/2/8","studentName":"侯元兴","clzssName":"3班","yswScore":85.0,"totalScore":150.0,"yswClzssRank":2,"totalClzssRank":2,"yswGradeRank":7,"totalGradeRank":8,"yswSubjectList":[{"score":85.0,"gradeRank":6,"clzssRank":2,"subjectBaseId":1,"subjectName":"数学"}],"extraSubjectList":[{"score":65.0,"gradeRank":15,"clzssRank":2,"subjectBaseId":4,"subjectName":"物理"}]},{"studentId":1250316,"clzssId":32552,"sex":"女","studentNo":"Y2016101955","interimStatus":1,"yswScoreRank":"85.0/2/6","totalScoreRank":"146.0/2/9","studentName":"汪娥京","clzssName":"1班","yswScore":85.0,"totalScore":146.0,"yswClzssRank":2,"totalClzssRank":2,"yswGradeRank":6,"totalGradeRank":9,"yswSubjectList":[{"score":85.0,"gradeRank":6,"clzssRank":2,"subjectBaseId":1,"subjectName":"数学"}],"extraSubjectList":[{"score":61.0,"gradeRank":21,"clzssRank":7,"subjectBaseId":4,"subjectName":"物理"}]},{"studentId":1250322,"clzssId":32552,"sex":"男","studentNo":"Y2016101961","interimStatus":1,"yswScoreRank":"74.0/3/14","totalScoreRank":"139.0/3/10","studentName":"苏小震","clzssName":"1班","yswScore":74.0,"totalScore":139.0,"yswClzssRank":3,"totalClzssRank":3,"yswGradeRank":14,"totalGradeRank":10,"yswSubjectList":[{"score":74.0,"gradeRank":14,"clzssRank":3,"subjectBaseId":1,"subjectName":"数学"}],"extraSubjectList":[{"score":65.0,"gradeRank":15,"clzssRank":5,"subjectBaseId":4,"subjectName":"物理"}]},{"studentId":1250310,"clzssId":32553,"sex":"男","studentNo":"Y2016101949","interimStatus":2,"yswScoreRank":"70.0/8/18","totalScoreRank":"139.0/6/10","studentName":"闫志志","clzssName":"2班","yswScore":70.0,"totalScore":139.0,"yswClzssRank":8,"totalClzssRank":6,"yswGradeRank":18,"totalGradeRank":10,"yswSubjectList":[{"score":70.0,"gradeRank":17,"clzssRank":7,"subjectBaseId":1,"subjectName":"数学"}],"extraSubjectList":[{"score":69.0,"gradeRank":10,"clzssRank":7,"subjectBaseId":4,"subjectName":"物理"}]},{"studentId":1250332,"clzssId":32554,"sex":"男","studentNo":"Y2016101971","interimStatus":1,"yswScoreRank":"90.0/1/4","totalScoreRank":"139.0/3/10","studentName":"黄彦成","clzssName":"3班","yswScore":90.0,"totalScore":139.0,"yswClzssRank":1,"totalClzssRank":3,"yswGradeRank":4,"totalGradeRank":10,"yswSubjectList":[{"score":90.0,"gradeRank":3,"clzssRank":1,"subjectBaseId":1,"subjectName":"数学"}],"extraSubjectList":[{"score":49.0,"gradeRank":28,"clzssRank":10,"subjectBaseId":4,"subjectName":"物理"}]},{"studentId":1250326,"clzssId":32553,"sex":"男","studentNo":"Y2016101965","interimStatus":1,"yswScoreRank":"73.0/6/16","totalScoreRank":"138.0/7/13","studentName":"马西斌","clzssName":"2班","yswScore":73.0,"totalScore":138.0,"yswClzssRank":6,"totalClzssRank":7,"yswGradeRank":16,"totalGradeRank":13,"yswSubjectList":[{"score":73.0,"gradeRank":16,"clzssRank":6,"subjectBaseId":1,"subjectName":"数学"}],"extraSubjectList":[{"score":65.0,"gradeRank":15,"clzssRank":10,"subjectBaseId":4,"subjectName":"物理"}]},{"studentId":1250312,"clzssId":32552,"sex":"女","studentNo":"Y2016101951","interimStatus":1,"yswScoreRank":"67.0/5/21","totalScoreRank":"136.0/4/14","studentName":"豆明侠","clzssName":"1班","yswScore":67.0,"totalScore":136.0,"yswClzssRank":5,"totalClzssRank":4,"yswGradeRank":21,"totalGradeRank":14,"yswSubjectList":[{"score":67.0,"gradeRank":21,"clzssRank":5,"subjectBaseId":1,"subjectName":"数学"}],"extraSubjectList":[{"score":69.0,"gradeRank":10,"clzssRank":3,"subjectBaseId":4,"subjectName":"物理"}]},{"studentId":1250336,"clzssId":32554,"sex":"男","studentNo":"Y2016101975","interimStatus":1,"yswScoreRank":"74.0/7/15","totalScoreRank":"134.0/4/15","studentName":"高猛成","clzssName":"3班","yswScore":74.0,"totalScore":134.0,"yswClzssRank":7,"totalClzssRank":4,"yswGradeRank":15,"totalGradeRank":15,"yswSubjectList":[{"score":74.0,"gradeRank":14,"clzssRank":7,"subjectBaseId":1,"subjectName":"数学"}],"extraSubjectList":[{"score":60.0,"gradeRank":22,"clzssRank":4,"subjectBaseId":4,"subjectName":"物理"}]},{"studentId":1250314,"clzssId":32552,"sex":"男","studentNo":"Y2016101953","interimStatus":1,"yswScoreRank":"68.0/4/20","totalScoreRank":"133.0/5/16","studentName":"侯春叶","clzssName":"1班","yswScore":68.0,"totalScore":133.0,"yswClzssRank":4,"totalClzssRank":5,"yswGradeRank":20,"totalGradeRank":16,"yswSubjectList":[{"score":68.0,"gradeRank":20,"clzssRank":4,"subjectBaseId":1,"subjectName":"数学"}],"extraSubjectList":[{"score":65.0,"gradeRank":15,"clzssRank":5,"subjectBaseId":4,"subjectName":"物理"}]},{"studentId":1250307,"clzssId":32553,"sex":"男","studentNo":"Y2016101946","interimStatus":1,"yswScoreRank":"70.0/7/17","totalScoreRank":"133.0/8/16","studentName":"孙勤云","clzssName":"2班","yswScore":70.0,"totalScore":133.0,"yswClzssRank":7,"totalClzssRank":8,"yswGradeRank":17,"totalGradeRank":16,"yswSubjectList":[{"score":70.0,"gradeRank":17,"clzssRank":7,"subjectBaseId":1,"subjectName":"数学"}],"extraSubjectList":[{"score":63.0,"gradeRank":19,"clzssRank":11,"subjectBaseId":4,"subjectName":"物理"}]},{"studentId":1250335,"clzssId":32554,"sex":"男","studentNo":"Y2016101974","interimStatus":1,"yswScoreRank":"79.0/6/13","totalScoreRank":"133.0/5/16","studentName":"焦伟飞","clzssName":"3班","yswScore":79.0,"totalScore":133.0,"yswClzssRank":6,"totalClzssRank":5,"yswGradeRank":13,"totalGradeRank":16,"yswSubjectList":[{"score":79.0,"gradeRank":13,"clzssRank":6,"subjectBaseId":1,"subjectName":"数学"}],"extraSubjectList":[{"score":54.0,"gradeRank":25,"clzssRank":7,"subjectBaseId":4,"subjectName":"物理"}]},{"studentId":1250333,"clzssId":32554,"sex":"男","studentNo":"Y2016101972","interimStatus":2,"yswScoreRank":"80.0/5/12","totalScoreRank":"132.0/6/19","studentName":"徐倩智","clzssName":"3班","yswScore":80.0,"totalScore":132.0,"yswClzssRank":5,"totalClzssRank":6,"yswGradeRank":12,"totalGradeRank":19,"yswSubjectList":[{"score":80.0,"gradeRank":11,"clzssRank":5,"subjectBaseId":1,"subjectName":"数学"}],"extraSubjectList":[{"score":52.0,"gradeRank":26,"clzssRank":8,"subjectBaseId":4,"subjectName":"物理"}]},{"studentId":1250309,"clzssId":32552,"sex":"女","studentNo":"Y2016101948","interimStatus":1,"yswScoreRank":"58.0/6/23","totalScoreRank":"129.0/6/20","studentName":"杨佰科","clzssName":"1班","yswScore":58.0,"totalScore":129.0,"yswClzssRank":6,"totalClzssRank":6,"yswGradeRank":23,"totalGradeRank":20,"yswSubjectList":[{"score":58.0,"gradeRank":23,"clzssRank":6,"subjectBaseId":1,"subjectName":"数学"}],"extraSubjectList":[{"score":71.0,"gradeRank":7,"clzssRank":2,"subjectBaseId":4,"subjectName":"物理"}]},{"studentId":1250328,"clzssId":32554,"sex":"男","studentNo":"Y2016101967","interimStatus":1,"yswScoreRank":"84.0/3/9","totalScoreRank":"127.0/7/21","studentName":"韩三","clzssName":"3班","yswScore":84.0,"totalScore":127.0,"yswClzssRank":3,"totalClzssRank":7,"yswGradeRank":9,"totalGradeRank":21,"yswSubjectList":[{"score":84.0,"gradeRank":8,"clzssRank":3,"subjectBaseId":1,"subjectName":"数学"}],"extraSubjectList":[{"score":43.0,"gradeRank":29,"clzssRank":11,"subjectBaseId":4,"subjectName":"物理"}]},{"studentId":1250318,"clzssId":32553,"sex":"男","studentNo":"Y2016101957","interimStatus":1,"yswScoreRank":"43.0/10/27","totalScoreRank":"125.0/9/22","studentName":"李计玲","clzssName":"2班","yswScore":43.0,"totalScore":125.0,"yswClzssRank":10,"totalClzssRank":9,"yswGradeRank":27,"totalGradeRank":22,"yswSubjectList":[{"score":43.0,"gradeRank":27,"clzssRank":10,"subjectBaseId":1,"subjectName":"数学"}],"extraSubjectList":[{"score":82.0,"gradeRank":2,"clzssRank":2,"subjectBaseId":4,"subjectName":"物理"}]},{"studentId":1250313,"clzssId":32552,"sex":"男","studentNo":"Y2016101952","interimStatus":1,"yswScoreRank":"55.0/7/24","totalScoreRank":"124.0/7/23","studentName":"李东军","clzssName":"1班","yswScore":55.0,"totalScore":124.0,"yswClzssRank":7,"totalClzssRank":7,"yswGradeRank":24,"totalGradeRank":23,"yswSubjectList":[{"score":55.0,"gradeRank":24,"clzssRank":7,"subjectBaseId":1,"subjectName":"数学"}],"extraSubjectList":[{"score":69.0,"gradeRank":10,"clzssRank":3,"subjectBaseId":4,"subjectName":"物理"}]},{"studentId":1250334,"clzssId":32554,"sex":"男","studentNo":"Y2016101973","interimStatus":1,"yswScoreRank":"62.0/8/22","totalScoreRank":"122.0/8/24","studentName":"软新军","clzssName":"3班","yswScore":62.0,"totalScore":122.0,"yswClzssRank":8,"totalClzssRank":8,"yswGradeRank":22,"totalGradeRank":24,"yswSubjectList":[{"score":62.0,"gradeRank":22,"clzssRank":8,"subjectBaseId":1,"subjectName":"数学"}],"extraSubjectList":[{"score":60.0,"gradeRank":22,"clzssRank":4,"subjectBaseId":4,"subjectName":"物理"}]},{"studentId":1250321,"clzssId":32553,"sex":"男","studentNo":"Y2016101960","interimStatus":1,"yswScoreRank":"80.0/5/11","totalScoreRank":"120.0/10/25","studentName":"温琼","clzssName":"2班","yswScore":80.0,"totalScore":120.0,"yswClzssRank":5,"totalClzssRank":10,"yswGradeRank":11,"totalGradeRank":25,"yswSubjectList":[{"score":80.0,"gradeRank":11,"clzssRank":5,"subjectBaseId":1,"subjectName":"数学"}],"extraSubjectList":[{"score":40.0,"gradeRank":30,"clzssRank":12,"subjectBaseId":4,"subjectName":"物理"}]},{"studentId":1250324,"clzssId":32553,"sex":"女","studentNo":"Y2016101963","interimStatus":1,"yswScoreRank":"43.0/11/28","totalScoreRank":"113.0/11/26","studentName":"冯晓斌","clzssName":"2班","yswScore":43.0,"totalScore":113.0,"yswClzssRank":11,"totalClzssRank":11,"yswGradeRank":28,"totalGradeRank":26,"yswSubjectList":[{"score":43.0,"gradeRank":27,"clzssRank":10,"subjectBaseId":1,"subjectName":"数学"}],"extraSubjectList":[{"score":70.0,"gradeRank":8,"clzssRank":6,"subjectBaseId":4,"subjectName":"物理"}]},{"studentId":1250331,"clzssId":32554,"sex":"女","studentNo":"Y2016101970","interimStatus":1,"yswScoreRank":"50.0/9/25","totalScoreRank":"113.0/9/26","studentName":"张蠡利","clzssName":"3班","yswScore":50.0,"totalScore":113.0,"yswClzssRank":9,"totalClzssRank":9,"yswGradeRank":25,"totalGradeRank":26,"yswSubjectList":[{"score":50.0,"gradeRank":25,"clzssRank":9,"subjectBaseId":1,"subjectName":"数学"}],"extraSubjectList":[{"score":63.0,"gradeRank":19,"clzssRank":3,"subjectBaseId":4,"subjectName":"物理"}]},{"studentId":1250329,"clzssId":32554,"sex":"男","studentNo":"Y2016101968","interimStatus":1,"yswScoreRank":"45.0/10/26","totalScoreRank":"95.0/10/28","studentName":"邵恒军","clzssName":"3班","yswScore":45.0,"totalScore":95.0,"yswClzssRank":10,"totalClzssRank":10,"yswGradeRank":26,"totalGradeRank":28,"yswSubjectList":[{"score":45.0,"gradeRank":26,"clzssRank":10,"subjectBaseId":1,"subjectName":"数学"}],"extraSubjectList":[{"score":50.0,"gradeRank":27,"clzssRank":9,"subjectBaseId":4,"subjectName":"物理"}]},{"studentId":1250320,"clzssId":32553,"sex":"男","studentNo":"Y2016101959","interimStatus":1,"yswScoreRank":"0.0/12/29","totalScoreRank":"73.0/12/29","studentName":"池崇民","clzssName":"2班","yswScore":0.0,"totalScore":73.0,"yswClzssRank":12,"totalClzssRank":12,"yswGradeRank":29,"totalGradeRank":29,"yswSubjectList":[{"score":0.0,"gradeRank":29,"clzssRank":12,"subjectBaseId":1,"subjectName":"数学"}],"extraSubjectList":[{"score":73.0,"gradeRank":6,"clzssRank":5,"subjectBaseId":4,"subjectName":"物理"}]},{"studentId":1250327,"clzssId":32554,"sex":"女","studentNo":"Y2016101966","interimStatus":1,"yswScoreRank":"-0.0/11/30","totalScoreRank":"60.0/11/30","studentName":"付尖旗","clzssName":"3班","yswScore":-1.0,"totalScore":60.0,"yswClzssRank":11,"totalClzssRank":11,"yswGradeRank":30,"totalGradeRank":30,"yswSubjectList":[{"score":-1,"gradeRank":-1,"clzssRank":-1,"subjectBaseId":1,"subjectName":"数学"}],"extraSubjectList":[{"score":60.0,"gradeRank":22,"clzssRank":4,"subjectBaseId":4,"subjectName":"物理"}]},{"studentId":1291868,"clzssId":32552,"sex":"男","studentNo":"00001","interimStatus":1,"yswScoreRank":"-0.0/8/31","totalScoreRank":"-0.0/8/31","studentName":"测试学生","clzssName":"1班","yswScore":-1.0,"totalScore":-1.0,"yswClzssRank":8,"totalClzssRank":8,"yswGradeRank":31,"totalGradeRank":31,"yswSubjectList":[{"score":-1,"gradeRank":-1,"clzssRank":-1,"subjectBaseId":1,"subjectName":"数学"}],"extraSubjectList":[{"score":-1,"gradeRank":-1,"clzssRank":-1,"subjectBaseId":4,"subjectName":"物理"}]}];
var mathArray = eval(list);
var newArray = [];
var absentStu = [];
for(var i=0;i<mathArray.length; i++){
var newStu = mathArray[i];
//语数外学科
if(subjectBaseId==1 || subjectBaseId==2 || subjectBaseId==3){
for(var j=0; j<mathArray[i].yswSubjectList.length; j++){
if(subjectBaseId == mathArray[i].yswSubjectList[j].subjectBaseId){
if(mathArray[i].yswSubjectList[j].gradeRank == -1){
absentStu.push(newStu);
}else{
newStu.sortGradeRank = mathArray[i].yswSubjectList[j].gradeRank;
newArray.push(newStu);
break;
}
}
}
}else{//其他学科
for(var j=0; j<mathArray[i].extraSubjectList.length; j++){
if(subjectBaseId == mathArray[i].extraSubjectList[j].subjectBaseId){
if(mathArray[i].extraSubjectList[j].gradeRank == -1){
absentStu.push(newStu);
}else{
newStu.sortGradeRank = mathArray[i].extraSubjectList[j].gradeRank;
newArray.push(newStu);
break;
}
}
}
}
}
newArray.sort(function(a,b){return a.sortGradeRank - b.sortGradeRank});
for(var i=0; i<absentStu.length; i++){
newArray.push(absentStu[i]);
}
for(var i =0; i<mathArray.length;i++){console.log(JSON.stringify(newArray[i]))};
</script>
以上是关于list内层的list的字段的排序的主要内容,如果未能解决你的问题,请参考以下文章