============================
var arr = [ { id: 2, name: 'xx2' }, { id: 3, name: 'xx3' }, { id: 4, name: 'xx4' }, { id: 1, name: 'xx1' } ]; arr.sort(function (a, b) { return a.id - b.id; }); console.log(arr);
============================
var arr = [ { id: 2, name: 'xx2' }, { id: 3, name: 'xx3' }, { id: 4, name: 'xx4' }, { id: 1, name: 'xx1' } ]; arr.sort(function (a, b) { return a.id - b.id; }); console.log(arr);
Welcome to Hexo! This is your very first post. Check documentation to learn how to use.