random.shuffled

Returns a copy of the array or the string with its elements shuffled.

Note

Uses Fisher-Yates shuffle with the cryptographically secure random number generator.

Syntax

shuffled(value)

Parameters

Return value

A copy of the array or the string with its elements shuffled.

Example

random.shuffled([1, 2, 3])
[3, 1, 2]
random.shuffled("Hey 😇")
"yH 😇e"
random.shuffled(new Uint8Array([1, 2, 3]))
Uint8Array [ 2, 3, 1 ]