排序字段 点击升序.倒序
const createComparisonFunction = function (propertyName,sortType) {
return function(object1, object2) {
var value1 = object1[propertyName];
var value2 = object2[propertyName];
if(value1 < value2) {
return -1*sortType;
} else if(value1 > value2) {
return 1*sortType;
} else {
return 0;
}
};
}
let listArr,sortTypeQf = 1;
listArr.sort(createComparisonFunction('LowPrice',sortTypeQf = sortTypeQf*-1)); //排序字段lowprice 点击升序.倒序