I need to shuffle the lines of a List Object to have a random 12-slots-sequence of the numbers 1-8 plus 4 blank spaces.
Is it possible?
I need to shuffle the lines of a List Object to have a random 12-slots-sequence of the numbers 1-8 plus 4 blank spaces.
Is it possible?
Just run a fastloop than randomly moves lines around for at least 12 iterations.
EDIT: I didn't realize that the List Object didn't have some action to move a line.
The way I like to shuffle a list is to use a second temporary list with all of the items, then randomly select from the list and move that random line to the end of the real list, deleting it from the temp list.
But either way you would need to store the randomized number, and working in a single list would be good.
Thank you. It's quite tricky. I think that adding a shuffle option to the List Object in the future could be useful to simplify the process.
On that same thought, a Move Line action seems like a necessity, and I don't understand why it doesn't have it already. Just a simple Move Line A to B.
If you need an example of the shuffling, I'd be glad to make you one.
To move a line you can insert a new line with the line-to-move's contents, then delete the original line.
Yes, but the problem occurs when you insert the new line before the original line. If it is inserted randomly you don't know which index to delete. You could get around this with FindString, I suppose.
Regardless, this system, as I tried it, isn't that great, and the best random method is to use 2 lists.
EDIT: Even better than using 2 lists is using the same logic all in one list. I'm attaching an example. Keep in mind what I said about using 2 lists to transfer the contents of one randomly to the other, and you should understand what I did.
Good point.
You could store the contents of the line, delete it and then insert the contents into the list at a random position.![]()


It's pretty simple.
http://www.whenthereisnoroominhellth...huffleList.mfa
One line of code.
ChrisBurrows, your example creates random empty lines... That's not good. It also depends on swapping lines a fixed amount of times (30 in your case). This means sometimes you get chunks of the list that stay the same and don't move.
Look at my example; it's even simpler, less actions, and completely randomizes any list quickly.


I only skimmed through the responses and didn't see you had beat me to it.
My example doesn't create empty lines. There are 4 empty lines already in the list object because Boba Fonts was after a "12-slots-sequence of the numbers 1-8 plus 4 blank spaces". The loop runs for 30 times for no particular reason. It is just a lot higher than 12. Running it for the number of lines in the list (aka 12) creates the exact same effect.
However, you do use less actions my friend, so I guess you win this round.
Ps. you wish you were shuffling ever day.