js - 按指定元素排序
that.tableData.sort(that.getSortFun('asc','ordertitle'));
getSortFun(order: any, sortBy: any) {
var ordAlpah = order == "asc" ? ">" : "<";
var sortFun = new Function(
"a",
"b",
"return a." + sortBy + ordAlpah + "b." + sortBy + "?1:-1"
);
return sortFun;
}
学贵有恒,而行胜于言