fix 权重排序

This commit is contained in:
2023-02-16 09:03:28 +08:00
parent 3b23b09909
commit addddbb8cc

View File

@@ -78,8 +78,11 @@ export default async function handler(
counts[smallestIndex][user][smallestIndex],
]);
}
weightList.sort((a, b) => a[1] - b[1] || a[2] - b[2]);
// console.log("weightList", weightList);
// 相同工时数量、相同权重的情况下随机选择
weightList.sort(
(a, b) => a[1] - b[1] || b[2] - a[2] || Math.random() - 0.5
);
console.log("weightList", smallestIndex, weightList);
const theChoosenUser = weightList[0][0];
// console.log("theChoosenUser", theChoosenUser);
// 记录结果