标签:
//对Object的num字段进行排序
var compare = function (propertyName) {
return function (object1, object2) {
var value1 = object1[propertyName]; var value2 = object2[propertyName]; if (value2 < value1) { return -1; } else if (value2 > value1) { return 1; } else { return 0; } } } Object.sort(compare(‘num‘));
标签:
原文地址:http://www.cnblogs.com/zyxzhsh/p/4932135.html