mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-14 13:16:11 +01:00
feat: shuffle button
This commit is contained in:
1 parent
ff4a87e5b8
commit
263f292a59
6 files changed
+33
-26
No files matched your search
@@ -0,0 +1,8 @@
|
||||
export function fisherYates<Type extends unknown[]>(array: Type) {
|
||||
for (let i = array.length - 1; i > 0; i--) {
|
||||
const j = Math.floor(Math.random() * (i + 1));
|
||||
[array[i], array[j]] = [array[j], array[i]];
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
Reference in new issue
Block a user