var data=[
{
    code: "10004",
    grade: "5.6",
    planQuantity: 220,
},
{
    code: "10024",
    grade: "5.6",
    planQuantity: 200,
},
{
    code: "10034",
    grade: "6.6",
    planQuantity: 210,
}
];
function orderSort(obj1,obj2){
    var a=obj1.planQuantity;
    var b=obj2.planQuantity;                                                    
    if(a>b){    
        return -1
    }else if(a<b){    
        return 1
    }else{
        return 0
    }              
};
data.sort(orderSort);

结果如下:使用sort对数组中的对象的某个属性进行排序

相关文章:

  • 2021-11-24
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-10-08
  • 2021-11-09
  • 2022-12-23
  • 2022-12-23
  • 2021-11-06
  • 2022-12-23
相关资源
相似解决方案