Randomize members list order in for loops

When using for loops for away ghost modes, or party random lights most of the samples does not randomize the order of light switching.

A simple and quick way of randomizing the order of members in a group for use in a for loop is to replace the sortBy function with a random function.

B_All_Lights.members.sortBy[g|(Math::floor(Math::random*100))].forEach(light,i |
          logInfo("Vacation","Hello Light" + light)

The above function will output the members of the B_All_Lights in a random order when called.

1 Like