Table of Contents
shuffle
Table of Contents
Prototype: shuffle(list, seed)
Return type: slist
Description: Return list
shuffled with seed
.
The same seed will produce the same shuffle every time. For a random shuffle,
provide a random seed with the randomint
function.
Arguments:
Example:
body common control
{
bundlesequence => { "test" };
}
bundle agent test
{
vars:
"mylist" slist => { "b", "c", "a" };
"seeds" slist => { "xx", "yy", "zz" };
"shuffled_$(seeds)" slist => shuffle(mylist, $(seeds));
"joined_$(seeds)" string => join(",", "shuffled_$(seeds)");
reports:
"shuffled RANDOMLY by $(seeds) = '$(joined_$(seeds))'";
}
Output:
R: shuffled RANDOMLY by xx = 'b,a,c'
R: shuffled RANDOMLY by yy = 'a,c,b'
R: shuffled RANDOMLY by zz = 'c,b,a'
See also: sort()
.