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;
  }
学贵有恒,而行胜于言
原文地址:https://www.cnblogs.com/huangbinlooksgood/p/14198724.html