let arr = [ { id: 1, weather:'晴' }, { id: 2, weather:'小雨' }, { id: 3, weather:'大雨' }, { id: 4, weather:'小雨' }, { id: 5, weather:'阴' }, { id: 6, weather:'雪' } ]; function sortData(a, b) { return b.id - a.id; }; arr.sort(sortData); console.log(arr);
数组对象排序
关注
打赏