mirror of
https://github.com/TheNetsky/Microsoft-Rewards-Script.git
synced 2026-01-10 18:36:17 +00:00
Make shuffleArray more random? (#254)
This commit is contained in:
@@ -18,11 +18,9 @@ export default class Util {
|
|||||||
}
|
}
|
||||||
|
|
||||||
shuffleArray<T>(array: T[]): T[] {
|
shuffleArray<T>(array: T[]): T[] {
|
||||||
const shuffledArray = array.slice()
|
return array.map(value => ({ value, sort: Math.random() }))
|
||||||
|
.sort((a, b) => a.sort - b.sort)
|
||||||
shuffledArray.sort(() => Math.random() - 0.5)
|
.map(({ value }) => value)
|
||||||
|
|
||||||
return shuffledArray
|
|
||||||
}
|
}
|
||||||
|
|
||||||
randomNumber(min: number, max: number): number {
|
randomNumber(min: number, max: number): number {
|
||||||
|
|||||||
Reference in New Issue
Block a user