标签:compare class property style pre sort res ret .so
//从大到小排序 function compareBigToSmall(property){ return function(a,b){ var value1 = a[property]; var value2 = b[property]; return value2 - value1; } }; //从小到大排序 function compareSmallToBig(property){ return function(a,b){ var value1 = a[property]; var value2 = b[property]; return value1-value2; } };
arr.sort(compareBigToSmall(‘balance‘));//从大到小排序
标签:compare class property style pre sort res ret .so
原文地址:http://www.cnblogs.com/ryans/p/6689442.html