[][src]Static p5_sys::global::shuffle

pub static shuffle: ShuffleInternalType

Randomizes the order of the elements of an array. Implements Fisher-Yates Shuffle Algorithm.

Examples

function setup() {
  let regularArr = ['ABC', 'def', createVector(), TAU, Math.E];
  print(regularArr);
  shuffle(regularArr, true); // force modifications to passed array
  print(regularArr);

  // By default shuffle() returns a shuffled cloned array:
  let newArr = shuffle(regularArr);
  print(regularArr);
  print(newArr);
}

Parameters

array Array to shuffle

bool? modify passed array