let list = [
{index:2,name:"老王"},
{index:1,name:"老张"},
{index:3,name:"老李"},
]
this.list.sort( (a, b) => {
return a.index - b.index
})
结果:
[
{index:1,name:"老张"},
{index:2,name:"老王"},
{index:3,name:"老李"},
]
let list = [
{index:2,name:"老王"},
{index:1,name:"老张"},
{index:3,name:"老李"},
]
this.list.sort( (a, b) => {
return a.index - b.index
})
结果:
[
{index:1,name:"老张"},
{index:2,name:"老王"},
{index:3,name:"老李"},
]