//排序数组

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) });