let a = [ {index:9},{index:5},{index:3},{index:4},{index:411},{index:1}]
//根据对象数组中的某一个值进行排序,如当前数组的index;
a.sort((a,b)=>a.index - b.index); //小->大
a.sort((a,b)=>b.index - a.index); //大->小
console.log(a);
Copyright© 2013-2020
All Rights Reserved 京ICP备2023019179号-8