mirror of
https://github.com/MartinKral/Slash-The-Hordes
synced 2026-02-14 12:22:42 +00:00
Pauser, game modal launcher
This commit is contained in:
10
assets/Scripts/Services/Utils/ArrayUtils.ts
Normal file
10
assets/Scripts/Services/Utils/ArrayUtils.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
export function shuffle<T>(array: T[]): T[] {
|
||||
const shuffledArray: T[] = [...array];
|
||||
|
||||
for (let i = shuffledArray.length - 1; i > 0; i--) {
|
||||
const j = Math.floor(Math.random() * (i + 1));
|
||||
[shuffledArray[i], shuffledArray[j]] = [shuffledArray[j], shuffledArray[i]];
|
||||
}
|
||||
|
||||
return shuffledArray;
|
||||
}
|
||||
Reference in New Issue
Block a user