const obj = [
{name:'1',bind:true},
{name:'2',bind:false},
{name:'3',bind:true},
{name:'4',bind:false},
{name:'8',bind:true},
{name:'9',bind:false}
]
obj.sort((a, b) => a.bind < b.bind)
console.log(10,obj)
打印结果:
[ { name: '1', bind: true },
{ name: '3', bind: true },
{ name: '8', bind: true },
{ name: '2', bind: false },
{ name: '4', bind: false },
{ name: '9', bind: false } ]