You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Jason Godesky edited this page Jul 11, 2026
·
1 revision
shuffleArray returns a new array with the same elements as the original array passed to it, but rearranged into a new, randomized order (using a Fisher–Yates shuffle). The array passed in is not mutated.
Parameters
arr: T[]
The array to shuffle.
Returns
A new array with all of the same elements as arr, but in a randomized order.
Examples
import{shuffleArray}from'@revolutionarygamesco/common'shuffleArray<number>([1,2,3])// Will return a new array with 1, 2, and 3, but in a randomized orderinterfaceTestCase{n: numberlabel: string}constcases: TestCase[]=[{n: 1,label: 'one'}{n: 2,label: 'two'},{n: 3,label: 'three'}]shuffleArray<TestCase>(cases)// Will return a new array with the three test cases, but in a randomized order