vue sort 排序方法
1、数据排序
var arry = [9,5,6,7,5,6,3,1,0] arry.sort() // [0, 1, 3, 5, 5, 6, 6, 7, 9]
2、对象排序
var list=[{name:'张三',age:12},{name:'李四','age:23}]; list.sort((a,b)=>{ return a.age - b.age });//[{name:'李四','age:23},{name:'张三',age:12}]
1、数据排序
var arry = [9,5,6,7,5,6,3,1,0] arry.sort() // [0, 1, 3, 5, 5, 6, 6, 7, 9]
2、对象排序
var list=[{name:'张三',age:12},{name:'李四','age:23}]; list.sort((a,b)=>{ return a.age - b.age });//[{name:'李四','age:23},{name:'张三',age:12}]