您可以使用最简单的方式:Lodash
(https://lodash.com/docs/4.17.10#orderBy)
此方法类似于_.sortBy,只是它允许指定要排序的迭代项的排序顺序。如果未指定顺序,则所有值都按升序排序。否则,为相应值的降序指定“desc”,为升序指定“asc”。
论据
collection(Array | Object):要迭代的集合。[iteratees=[_.identity]](数组[]|函数[]|对象[]|字符串[]):要排序的iterates。[orders](string[]):迭代的排序顺序。
退换商品
(Array):返回新的排序数组。
var _ = require('lodash');
var homes = [
{"h_id":"3",
"city":"Dallas",
"state":"TX",
"zip":"75201",
"price":"162500"},
{"h_id":"4",
"city":"Bevery Hills",
"state":"CA",
"zip":"90210",
"price":"319250"},
{"h_id":"6",
"city":"Dallas",
"state":"TX",
"zip":"75000",
"price":"556699"},
{"h_id":"5",
"city":"New York",
"state":"NY",
"zip":"00010",
"price":"962500"}
];
_.orderBy(homes, ['city', 'state', 'zip'], ['asc', 'desc', 'asc']);