@lelantos-org/sdk / core / shuffled
Function: shuffled() โ
ts
function shuffled<T>(items, pick?): T[];Defined in: @lelantos-org/sdk/dist/core/random.d.ts:47
A uniformly random permutation of items, as a new array.
FisherโYates, downwards, so every one of the n! orderings is equally likely โ given an unbiased pick, which is why the default is randomBelow and not a scaled float.
pick(k) must return a uniform integer in [0, k); injecting one is how a test pins a specific permutation.
Type Parameters โ
| Type Parameter |
|---|
T |
Parameters โ
| Parameter | Type |
|---|---|
items | readonly T[] |
pick? | (n) => number |
Returns โ
T[]