js排序
// 数组排序
var arr = [123, 203, 23, 13, 34, 65, 65, 45, 89, 13, 1];
function func(a, b) {
return a - b;
}
var arrs = arr.sort(func);
console.log(arrs)
// 对象排序
var result = [{id: 1,name: '中国银行'},
{id: 3,name: '北京银行'},
{id: 2,name: '河北银行'},
{id: 10,name: '保定银行'},
{id: 7,name: '涞水银行'}
]
function sortId(a, b) {
return a.id - b.id
}
result.sort(sortId);
console.log(result);