Having issues with shuffling an array

I found this method of shuffling an array or tables is it? from me following a tutorial on how to make a Music Player

for i = 1, #queue - 1 do -- queue as in your table name obviously
		local r = math.random(i,#queue)
		queue[i], queue[r] = queue[r], queue[i]

I really dont know how to explain this but its called Fisher-Yates Shuffle
Also big thanks to the guy making this music player tutorial Really appreciated his work :smiley:

5 Likes