已领取项沉底,可领取项置顶
enum State {
incomplete, //未完成
available, //可领取
complete, //已领取
}
list.sort((a, b) => {
if (a.state !=== b.state) {
if (a.state === State.complete) {
return 1;
} else if (b.state === State.complete) {
return -1;
} else {
return b.state - a.state;
}
} else {
return a.id - b.id;
}
};