军团&好友:推荐列表做一下乱序

This commit is contained in:
luying
2021-02-23 16:46:52 +08:00
parent 92d223314b
commit 93eaee5032
6 changed files with 21 additions and 9 deletions
+9
View File
@@ -293,6 +293,15 @@ export function getRandEelm(source: Array<any> = [], cnt = 1): Array<any> {
return source.filter((_item, idx) => idxs.has(idx));
}
/**
* 不改变原数组长度,将内部元素打乱
* @param source
*/
export function sortArrRandom(source = []) {
let arr = deepCopy(source);
return arr.sort(() => { return Math.random()-0.5; });
}
/**
* 在给定数值的浮动范围中随机一个值
* @param base 基础数值