How to shuffle a list within a list

For the following code, I would like to shuffle rows (startpositions, cueobjects, and targetobjects). So the row doesn’t go from [0] to [1]; instead, it can go [6] then [8] etc. I was wondering if anyone knows a way of randomizing the list and then creates a list. Thanks!

For example,
From this

        List<List<GameObject>> pairs = new List<List<GameObject>>()
        {
            new List<GameObject>{ taskInfo.StartPositions[0], taskInfo.CueObjects[0], taskInfo.TargetObjects[0]},
            new List<GameObject>{ taskInfo.StartPositions[1], taskInfo.CueObjects[1], taskInfo.TargetObjects[1]},
            new List<GameObject>{ taskInfo.StartPositions[2], taskInfo.CueObjects[2], taskInfo.TargetObjects[2]},
            new List<GameObject>{ taskInfo.StartPositions[3], taskInfo.CueObjects[3], taskInfo.TargetObjects[3]},
            new List<GameObject>{ taskInfo.StartPositions[4], taskInfo.CueObjects[4], taskInfo.TargetObjects[4]},
            new List<GameObject>{ taskInfo.StartPositions[5], taskInfo.CueObjects[5], taskInfo.TargetObjects[5]},
            new List<GameObject>{ taskInfo.StartPositions[6], taskInfo.CueObjects[6], taskInfo.TargetObjects[6]},
            new List<GameObject>{ taskInfo.StartPositions[7], taskInfo.CueObjects[7], taskInfo.TargetObjects[7]},
            new List<GameObject>{ taskInfo.StartPositions[8], taskInfo.CueObjects[8], taskInfo.TargetObjects[8]},
            new List<GameObject>{ taskInfo.StartPositions[9], taskInfo.CueObjects[9], taskInfo.TargetObjects[9]},

        };

To

        List<List<GameObject>> pairs = new List<List<GameObject>>()
        {
            new List<GameObject>{ taskInfo.StartPositions[4], taskInfo.CueObjects[4], taskInfo.TargetObjects[4]};
            new List<GameObject>{ taskInfo.StartPositions[0], taskInfo.CueObjects[0], taskInfo.TargetObjects[0]},
            new List<GameObject>{ taskInfo.StartPositions[6], taskInfo.CueObjects[6], taskInfo.TargetObjects[6]},
            new List<GameObject>{ taskInfo.StartPositions[1], taskInfo.CueObjects[1], taskInfo.TargetObjects[1]},
            new List<GameObject>{ taskInfo.StartPositions[2], taskInfo.CueObjects[2], taskInfo.TargetObjects[2]},
            new List<GameObject>{ taskInfo.StartPositions[3], taskInfo.CueObjects[3], taskInfo.TargetObjects[3]},
            new List<GameObject>{ taskInfo.StartPositions[8], taskInfo.CueObjects[8], taskInfo.TargetObjects[8]},
            new List<GameObject>{ taskInfo.StartPositions[9], taskInfo.CueObjects[9], taskInfo.TargetObjects[9]},
            new List<GameObject>{ taskInfo.StartPositions[5], taskInfo.CueObjects[5], taskInfo.TargetObjects[5]},
            new List<GameObject>{ taskInfo.StartPositions[7], taskInfo.CueObjects[7], taskInfo.TargetObjects[7]},
           

        };

So you want to shuffle, for example, the first COLUMN, the one with StartPositions? The way you have it you can’t use a pre-made shuffle, since the rows are lists, not the columns. But you could grab some shuffle code and rewrite the guts. To swap StartPositions at rows i1 and i2 use pairs[i1][0] and pairs[i2][0] (i1 and i2 are the rows, and 0 is the first item, StartPositions).

It also seems as if you could build pairs more easily using a loop, abd pairs.Add( … )

I want to only swap the rows so it would look something like this- the startposition, cueobjects, and targetobjects would also be paired together with the same number

        List<List<GameObject>> pairs = new List<List<GameObject>>()
        {
            new List<GameObject>{ taskInfo.StartPositions[4], taskInfo.CueObjects[4], taskInfo.TargetObjects[4]};
            new List<GameObject>{ taskInfo.StartPositions[0], taskInfo.CueObjects[0], taskInfo.TargetObjects[0]},
            new List<GameObject>{ taskInfo.StartPositions[6], taskInfo.CueObjects[6], taskInfo.TargetObjects[6]},
            new List<GameObject>{ taskInfo.StartPositions[1], taskInfo.CueObjects[1], taskInfo.TargetObjects[1]},
            new List<GameObject>{ taskInfo.StartPositions[2], taskInfo.CueObjects[2], taskInfo.TargetObjects[2]},
            new List<GameObject>{ taskInfo.StartPositions[3], taskInfo.CueObjects[3], taskInfo.TargetObjects[3]},
            new List<GameObject>{ taskInfo.StartPositions[8], taskInfo.CueObjects[8], taskInfo.TargetObjects[8]},
            new List<GameObject>{ taskInfo.StartPositions[9], taskInfo.CueObjects[9], taskInfo.TargetObjects[9]},
            new List<GameObject>{ taskInfo.StartPositions[5], taskInfo.CueObjects[5], taskInfo.TargetObjects[5]},
            new List<GameObject>{ taskInfo.StartPositions[7], taskInfo.CueObjects[7], taskInfo.TargetObjects[7]},
           

        };

Here’s a link to different ways to shuffle a list

Personally I’d create a list with all the numbers(as you call them) and shuffle that instead.

Then you can just iterate over that list and populate your pairs list with the shuffled indices

something like

for (int i = 0; i < shuffledIndices.Count; i++)
{
    int index = shuffledIndices[i];
    pairs.Add(List<GameObject>{ taskInfo.StartPositions[index], taskInfo.CueObjects[index], taskInfo.TargetObjects[index] });
}