diff --git a/src/core/PseudoRandom.ts b/src/core/PseudoRandom.ts index 39ef87ab0..daf27497f 100644 --- a/src/core/PseudoRandom.ts +++ b/src/core/PseudoRandom.ts @@ -108,14 +108,11 @@ export class PseudoRandom { * Returns a shuffled copy of the array using Fisher-Yates algorithm. */ shuffleArray(array: T[]): T[] { - // Create a copy to avoid modifying the original array - const arrayCopy = [...array]; - - for (let i = arrayCopy.length - 1; i >= 0; i--) { + for (let i = array.length - 1; i >= 0; i--) { const j = this.nextInt(0, i + 1); - [arrayCopy[i], arrayCopy[j]] = [arrayCopy[j], arrayCopy[i]]; + [array[i], array[j]] = [array[j], array[i]]; } - return arrayCopy; + return array; } }