How to make multiple selections from a list

Hi @N_Saito , if you are concerned about duplicates, you can 1. first sort the list in a random order (see How To Randomize List Order? - #4 by scott) and then 2. pick the first two items from it, like this:

{sentences=["This is a sentence", "This is also a sentence", "I am another sentence", "This is the fourth sentence in my list", "I am the fifth sentence"]; trim=yes}

{randomizelist=(list) -> map(sort(map(list, x -> ["id":random(), "value":x]), (a,b) -> a.id - b.id), x -> x.value); trim=yes}

{random_sentences=randomizelist(sentences); trim=yes}

{sentence1=random_sentences[1]; trim=yes}
{sentence2=random_sentences[2]; trim=yes}

First sentence: {=sentence1}
Second sentence: {=sentence2}

2 Likes