let obj = {
drawerList:[
{url:'../../static/images/icon/coin-etc.png',name:'ETC',zhangfu:+122.33,price:228.253,about:3.3248,state:1},
{url:'../../static/images/icon/coin-bat.png',name:'BAT',zhangfu:-12.20,price:68.53,about:3.3248,state:0},
{url:'../../static/images/icon/coin-gram.png',name:'GRA',zhangfu:+121.13,price:68.3223022,about:3.3248,state:1},
{url:'../../static/images/icon/coin-eth.png',name:'ETH',zhangfu:+12.83,price:68.25232,about:3.3248,state:1},
{url:'../../static/images/icon/coin-bat.png',name:'BAT',zhangfu:-122.03,price:12.25322232,about:3.3248,state:0},
{url:'../../static/images/icon/coin-etc.png',name:'ETC',zhangfu:-12.13,price:68.253232,about:3.3248,state:0},
{url:'../../static/images/icon/coin-bat.png',name:'BAT',zhangfu:-9.03,price:68.253232,about:3.3248,state:0},
]
}
//
let arr = obj.drawerList.concat();
//
arr.sort(function(i,j){
return i.zhangfu - j.zhangfu
})
let data = [
{url:'../../static/images/icon/coin-etc.png',name:'ETC',zhangfu:+122.33,price:228.253,about:3.3248,state:1},
{url:'../../static/images/icon/coin-bat.png',name:'BAT',zhangfu:-12.20,price:68.53,about:3.3248,state:0},
{url:'../../static/images/icon/coin-gram.png',name:'GRA',zhangfu:+121.13,price:68.3223022,about:3.3248,state:1},
{url:'../../static/images/icon/coin-eth.png',name:'ETH',zhangfu:+12.83,price:68.25232,about:3.3248,state:1},
{url:'../../static/images/icon/coin-bat.png',name:'BAT',zhangfu:-122.03,price:12.25322232,about:3.3248,state:0},
{url:'../../static/images/icon/coin-etc.png',name:'ETC',zhangfu:-12.13,price:68.253232,about:3.3248,state:0},
{url:'../../static/images/icon/coin-bat.png',name:'BAT',zhangfu:-9.03,price:68.253232,about:3.3248,state:0}
]
// slice
let result1 = data.slice().sort((a, b) => a.zhangfu - b.zhangfu) //
let result2 = data.slice().sort((a, b) => b.zhangfu - a.zhangfu) //
var drawerList = [
{url:'../../static/images/icon/coin-etc.png',name:'ETC',zhangfu:+122.33,price:228.253,about:3.3248,state:1},
{url:'../../static/images/icon/coin-bat.png',name:'BAT',zhangfu:-12.20,price:68.53,about:3.3248,state:0},
{url:'../../static/images/icon/coin-gram.png',name:'GRA',zhangfu:+121.13,price:68.3223022,about:3.3248,state:1},
{url:'../../static/images/icon/coin-eth.png',name:'ETH',zhangfu:+12.83,price:68.25232,about:3.3248,state:1},
{url:'../../static/images/icon/coin-bat.png',name:'BAT',zhangfu:-122.03,price:12.25322232,about:3.3248,state:0},
{url:'../../static/images/icon/coin-etc.png',name:'ETC',zhangfu:-12.13,price:68.253232,about:3.3248,state:0},
{url:'../../static/images/icon/coin-bat.png',name:'BAT',zhangfu:-9.03,price:68.253232,about:3.3248,state:0},
]
function sortList(a, b) {
return b.zhangfu - a.zhangfu
}
drawerList.sort(sortList)
console.log(drawerList)
drawerList.sort((a, b) => a.zhangfu - b.zhangfu)
drawerList.sort ((hr class= b) = > {return a.zhangfub.zhangfu;})
//
drawerList.sort((a, b) => {
return a.zhangfu-b.zhangfu
});
//
drawerList.sort((a, b) => {
return b.zhangfu-a.zhangfu
});
omnipotent sort and power, don't think about that bunch of sorting methods
drawerList = ary.sort((a, b) => a.zhangfu - b.zhangfu)