标签:val redo bsp rop turn 参数 字母 red code
// 升序 function compare(property) { return function (a, b) { var value1 = a[property]; var value2 = b[property]; return value1 - value2; } } // 降序 function compareDown(property) { return function (a, b) { var value1 = a[property]; var value2 = b[property]; return (value1 - value2) * -1; } } // [{ aaa: "" }, { aaa: "" }, { aaa: "" }] Array.sort(compare(‘aaa‘)) Array.sort(compareDown(‘aaa‘)) Array.sort((a, b) => a.aaa.localeCompare(b.aaa, ‘zh‘)); //a~z 排序 Array.sort((a, b) => b.aaa.localeCompare(a.aaa, ‘zh‘)); //z~a 排序
标签:val redo bsp rop turn 参数 字母 red code
原文地址:https://www.cnblogs.com/XUYIYUAN/p/11298608.html