Skip to main content

Description

Randomly shuffles the elements of a list using the Fisher-Yates algorithm. Returns a new list with elements in random order without modifying the original.

Syntax

Parameters

Returns

Type: list A new list containing the same elements in a randomized order. Returns an empty list if input is not an array.

Examples

Example 1: Basic Shuffle

Output: (example, actual order will vary)

Example 2: Random Sample Selection

Example 3: Randomizing Recommendations

Example 4: Random Team Assignment

Notes

  • Returns empty list if input is not an array or is null
  • Uses the Fisher-Yates shuffle algorithm for uniform random distribution
  • Creates a new list; does not modify the original
  • Each element appears exactly once in the result
  • Order is truly random on each execution

See Also

  • coll.zip - Combine two lists element-by-element
  • coll.union - Combine unique elements from lists

Frequently Asked Questions

No. flex.coll.shuffle produces a random permutation each time it is called, so results will vary between executions.
No. It returns a new shuffled list; the original remains unchanged.