美文网首页
对象数组降序或者升序

对象数组降序或者升序

作者: Mark_ZSQ | 来源:发表于2019-12-08 11:52 被阅读0次
    let arr = [
        {name: '西安市1', value: '100%'},
        {name: '西安市2', value: '99%'},
        {name: '西安市3', value: '100%'},
        {name: '威阳市2', value: '88.2%'},
        {name: '榆林市2', value: '66.6%'},
        {name: '榆林市1', value: '34.2%'},
        {name: '延安市4', value: '80%'},
        {name: '南洛市2', value: '90%'},
        {name: '榆林市9', value: '81.3%'},
        {name: '榆林市0', value: '34.2%'}
    ];
    
    
    arr.sort((a, b) => {
        return parseInt(b.value) - parseInt(a.value)
    });
    
    arr.sort((a, b) => {
        return parseInt(a.value) - parseInt(b.value)
    });
    

    相关文章

      网友评论

          本文标题:对象数组降序或者升序

          本文链接:https://www.haomeiwen.com/subject/chkmgctx.html