import console; import string.conv; io.open();//打开控制台 var 成绩单={ {name="王小春";grade="二年级";score=80}; {name="黄日华";grade="四年级";score=90}; {name="梁朝伟";grade="三年级";score=70}; {name="刘嘉玲";grade="四年级";score=100}; {name="成龙";grade="二年级";score=95}; } io.print("原排序:"); console.varDump(成绩单); table.sort(成绩单,function(b){ var owner_name_pinyin=string.conv.pinyin(owner.name,""); var b_name_pinyin=string.conv.pinyin(b.name,""); if(owner.grade<b.grade){ return true; } elseif(owner.grade==b.grade){ return owner_name_pinyin<b_name_pinyin; } return false; }); io.print("按年级升序,姓名升序排序:"); console.varDump(成绩单);
execute("pause") //按任意键继续 io.close();//关闭控制台
那个table排序的答案 - aardio - aardio 官方社区 - Powered by Discuz! |