//从大到小排序 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'));//从大到小排序