loading...

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;
  }
posted @ 2020-12-27 21:11  robinloveslife  阅读(457)  评论(0编辑  收藏  举报