Json数组排序
Posted 绯颜旧雨
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Json数组排序相关的知识,希望对你有一定的参考价值。
语法:arraylist.sort(sortby);
sortby:排序函数;
例子:st=[{"ID":15,"trees":2,"NodeNM":" 省属","isLeaf":1,"haveData":null,"行政区划":"4290","项目类型":null},{"ID":14,"trees":2,"NodeNM":" 恩施土家族苗族自治州","isLeaf":1,"haveData":null,"行政区划":"4228","项目类型":null},{"ID":13,"trees":2,"NodeNM":" 随州市","isLeaf":1,"haveData":null,"行政区划":"4213","项目类型":null},{"ID":12,"trees":2,"NodeNM":" 咸宁市","isLeaf":1,"haveData":null,"行政区划":"4212","项目类型":null}];
function sortby(a,b)
{
return a.行政区划-b.行政区划
}
st.sort(sortby);
来源:https://www.cnblogs.com/jasonwang2y60/p/6656103.html
以上是关于Json数组排序的主要内容,如果未能解决你的问题,请参考以下文章