ES5
JSON.stringify(obj, function(_, v) {
return (!(v instanceof Array || v === null) && typeof v == "object") ? Object.keys(v).sort().reduce(function(r, k) { r[k] = v[k]; return r }, {}) : v;
});
ES2015
JSON.stringify(obj, (_, v) => (!(v instanceof Array || v === null) && typeof v == "object") ? Object.keys(v).sort().reduce((r, k) => { r[k] = v[k]; return r }, {}) : v);
[参考]
http://stackoverflow.com/questions/5467129/sort-javascript-object-by-key/29622653#29622653