varobj=[{id:1,age:20,top:5},{id:3,age:21,top:6},{id:2,age:20,top:8}]functionkeysort(property){returnfunction(a,b){varvalue1=a[property]=='-'?0:a[property];varvalue2=b[property]=='-'?0:b[property];returnvalue1-value2;}}varobj1=obj.sort(keysort('age'));写一半不会写了age相同的情况下再按照top从高到低排序想请教下老司机
相关分类