Shuffle Array via Lotusscript

Posted on: May 10th, 2012 by Raz


%REM
Function arrayShuffle
Description: Lotuscript Shuffle Array Function
%END REM
Function arrayShuffle(arrayData As Variant) As Variant

Dim y As Integer
Dim randomPos As Integer
Dim tmp As Variant

For y = 0 To UBound(arrayData)
randomPos = Round(Rnd() * UBound(arrayData),0)
tmp = arrayData(y)

arrayData(y) = arrayData(randomPos)
arrayData(randomPos) = tmp
Next

arrayShuffle = arrayData
End Function