无为清净楼资源网 Design By www.qnjia.com
复制代码 代码如下:
//排序数组
function SortBy(field, reverse, primer) {
reverse = (reverse) ? -1 : 1;
return function (a, b) {
a = a[field];
b = b[field];
if (typeof (primer) != 'undefined') {
a = primer(a);
b = primer(b);
}
if (a < b) return reverse * -1;
if (a > b) return reverse * 1;
return 0;
}
}
nodes.sort(SortBy('orderNum', false, parseInt));

把过个字段合并成单个 然后 排序字符串
复制代码 代码如下:
nodes.sort(function (a, b) { return a.sort.localeCompare(b.sort) });
标签:
JSON,数字排序,多字段排序

无为清净楼资源网 Design By www.qnjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
无为清净楼资源网 Design By www.qnjia.com

更新日志

2024年10月04日