jquery利用sort方法对json数据排序
var jsonData = [{ModuleId: "cda2c478", EnCode: "work", FullName: "工务","Sort":2},{ModuleId: "8474a702", EnCode: "Setting", FullName: "设置", ,"Sort":1},{ModuleId: "76b37fcb", EnCode: "Emp", FullName: "成员",,"Sort":3}]; console.info("排序之前:" + jsonData); jsonData.sort(function(a,b) { return a.Sort - b.Sort; }); console.info("排序之后:" + jsonData);
如果对FullName字段进行排序,只需要修改a.FullName-b.FullName即可。
微信号:jamesworkshop 学习QQ群:364976091