Twine 2: Sorting People/Things into Groups?

So I’m rather new to Twine and I thought about making a game where the player character and a number of other students are sorted into different dorm rooms in a college. Basically, I need a script that will take a predetermined list of characters and sort them into different groups, like so:

Say there were four students; Sally, Harry, Greg, and Molly. The script I’m looking for would randomize the organization such that Sally and Greg could end up in one dorm, while Harry and Molly wound up in the other, or any other combination thereof. But because I don’t have a lot of experience with Twine, I’m not sure how to even begin setting this up…

Thanks in advance!

If you are using the Twine desktop app with Harlowe then one way is to use shuffled:

(set: $roomies to (shuffled:'Sally','Harry','Greg','Molly'))
- [[Room A]]
- [[Room B]]

Room A
(print: $roomies[0]) and (print: $roomies[1]) are here.

Room B
(print: $roomies[2]) and (print: $roomies[3]) are here.

Notice that in this case the roomies will shuffle each time you walk through the Hallway – that is good for testing, but you might not want that in a realistic work.

Thanks! That seems to work fine!