The end result is pretty much the same for either shuffle. I'm always on the look for a simpler way to do it.
You can do that rearranging with just text like so:
listA = "DCAB"
listB = "3142"
listC = ""
start of layout
repeat 4 times
-- add mid(listA, find(listB, str(loopindex+1)), 1) to listC
To do it with picking sprites it would be tedious. You can convert a row of sprites to text with:
list = ""
start of layout
sprite: group=0
for each sprite ordered by sprite.x
-- add str(sprite.animationFrame) to list
or you can use one of these in the add to list action if you want named frames
mid("ABCD", sprite.animationFrame, 1)
mid("1234", sprite.animationFrame, 1)
Thank you very much! This command to generate the lists is very useful but I think I don't know how to use it correctly. I spent all morning trying to implement it so I could only say thank you, but I couldn't.
I have to cross two pieces of information to be able to find the third.
The situation is like this:
1) I have the 4 letters being generated randomly and being displayed in 4 instances of sprite1 (eg DABC). The list of frames is stored in the variable seqLetters (3012)
2) I have the 4 numbers being randomly generated and being displayed in 4 instances of sprite2 (eg 4132). The frame list is stored in the seqNumbers variable (3021)
Problem:
Now I have to show the result in the 4 instances of sprite3, positioning each letter present in sprite1, in the position determined by sprite2 (ex. CDBA), that is, first the letter of position 4, then the letter of position 1, then the letter of position 3 and finally the letter of position 2)
I'm using the first command block you suggested, but I can't get the result.
repeat 4 times
--add mid(seqLetters, find(seqNumbers, str(loopindex+1)), 1) to seq
for each sprite3 order by sprite1.X ascending
-- set Animation Frame to int(mid(seq, loopindex, 1))