我要排序的 JSON 示例:{ "auctions": [{ "uuid": "533cbc92429c4456b2c013607eed5c38", "auctioneer": "5ba9f43481854fe891f94dfbd771b065", "profile_id": "4bec273ae4fa4ebd80169b734d0702bc", "coop": ["5ba9f43481854fe891f94dfbd771b065"], "start": 1600978137016, "end": 1600999737016, "item_name": "Hologram", "item_lore": "§8Furniture\n§8Colored\n\n§7Add some flare to your island\n§7with custom floating text!\n\n§6§lLEGENDARY", "extra": "Hologram Skull Item", "category": "misc", "tier": "LEGENDARY", "starting_bid": 300000, "item_bytes": "H4sIAAAAAAAAAE1Ry26bQBS9dtIG01b5gkpUyhYFbAOmUheWTQKWAcfPmE01mIGMMwMWDE3wP/Q7vO03+MOqTtpNV1f3nHPPfckAHWgRGQBabWiTpPWzBe9GRZ3zlgwXHGUX0HFJgu8oyiqh+i2DvHiuKQ1fclxK0PYSuNGsLsYxMlUr1W21Z5qGag+6qYoslMZmjLAV66JuVhYHXHKCqw5IHL/yusTV39YSvFsjWmP4hZuJFj0+acnjhO4azxT5cqHR0NsfLC9fN/HIMz0meHdoThv7P63B0cag297kKcof6pittWlvTrE713ds9SMcJzRazmkwzoxg4xjbY0T9/cPR/xe7wX69D5bbYzj2ej5zjhFb0+3GN4Llqh+OJyzaPzfbzero7x1dxF5EJnb6qH0T08twlZDqQFHTgctpUWJJgFfw8Xwa3NVlTt7WBFlko4IKNhGscj5ZwyRRqoJhJaWoxAovlKaoS4VUFOUJfBaKF8KflF1d8YIJUYE4yTPl7W5fhMX1+WSeT3Tq3DvBeDjfSnAZIIbhg8Bd0SgrEROjXTuvvERDzksS1xxXEnSKkmQkX6IMPi3ccPZ9tpqP3OHCkd7+D5IbTsP7+dAXhnUtgBsztZHdTRM11nWk9gcWVm1s9NXdzhzocZrEtqEJW04YrjhiB7i2b7v9266m9L9qA2XmA7Th/RgxlGG4APgDfkDxxHQCAAA=", "claimed": false, "claimed_bidders": [], "highest_bid_amount": 0, "bin": true, "bids": [] }
4 回答
动漫人物
TA贡献1815条经验 获得超10个赞
从最低到最高:
myJson.auctions.sort((a,b)=>a.starting_bid-b.starting_bid)
从最高到最低:
myJson.auctions.sort((a,b)=>b.starting_bid-a.starting_bid)
慕田峪9158850
TA贡献1794条经验 获得超7个赞
你可以这样做:
var array=[],obj={
caffeineoverdose:'2517',
workhardplayhard:'761277',
familia:'4633452'
};
for(a in obj){
array.push([a,obj[a]])
}
array.sort(function(a,b){return a[1] - b[1]});
array.reverse();
小怪兽爱吃肉
TA贡献1852条经验 获得超1个赞
现场演示在这里
const input = ...
let output = input.auctions.sort( (a,b) => a.starting_bid -b.starting_bid > 0);
炎炎设计
TA贡献1808条经验 获得超4个赞
你可以使用 sort =D
const sort = a['auctions'].sort((a,b) => a['starting_bid'] - b['starting_bid'])
添加回答
举报
0/150
提交
取消