1. 程式人生 > >自定義字段排序

自定義字段排序

date 自定義字段 iso multi pair 設置 AS this clas

//排序方法
multisort(array, ...compairers) {
    return array.sort((a, b) => {
      for (const c of compairers) {
          const r = c(a, b);
          if (r !== 0) {
              return r;
                  }
          }
     });
},
//設置排序字段
this.multisort(pageList,    //data數組
              (a, b) => b.date - a.date,
              (a, b) 
=> b.userNum - a.userNum, (a, b) => b.succUserRatio - a.succUserRatio);

自定義字段排序