Sofa_King
he is subtracting one in the first event because arrays are zero based... so if the array has a width of 10 (10 values stored in the array), then those entries will be numbered 0 to 9.
the routine starts with the LAST entry in the array and picks a random entry up to that point in the array and swaps the values. And then does the second last one, etc...
so at the end of the loop, each value in the array has had a chance to be swapped at least once.
the tempValue variable is a text variable, so it will work with text values.
if you don't have the -1 as shown, you could end up swapping with a value outside the array limits - which would probably give you a zero value.
to walk through the logic: (for an array with 10 items)
the first time the loop runs, loopindex will be zero, so randomindex will be int(random(10-0))
note that random will pick a number up to, but NOT including the limit you give it, so in this case it will pick a number between 0 and 9.9999... and then take the integer portion (to give you a number between 0 and 9).
then it sets tempValue to the last entry in the array (which is 10-0-1), and then swaps that value with the randomly picked entry.
then the loop repeats, loopindex will be 1, so randomindex will be a number between 0 and 8, and the second last entry (10-1-1) is swapped with that.
repeat, loopindex will be 2, randomindex will be 0 to 7, swap with (10-2-1) or 7th entry
The final time the loop runs, loopindex will be 9, so randomindex will be 0, and it will swap with itself (10-9-1).
This guaranties that every item in the array has had a chance to swap with another position in the array.
EDIT: just looked at your shuffle code, and the reason it was not working is that "pick" could choose the same value multiple times, and that would result in loopindex getting overwritten in the array, and then you would also have at least other array value never getting set. You would have to use a method that must pick a unique value. (the tutorial you linked to put 4 values in a temp array, and then deleted the picked value each time through the next loop so it could not be picked again).