您的位置:首页 > 其它

比较函数

2014-04-02 10:00 246 查看
function createComparisonFunction(propertyName) {
return function(obj1, obj2) {
var value1 = obj1.getAttribute(propertyName),
value2 = obj2.getAttribute(propertyName);
if (value1 < value2) {
return -1;
} else if (value1 > value2) {
return 1;
} else {
return 0;
}
}
}


可用于排序的比较函数
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: