shuffle
Randomize a list, and make the shuffle reproducible
- list
- list
Want to scramble the order of a list - prompts, seeds, candidate images - so each run deals a different hand? DataListShuffle takes a list and a seed and returns a new list in randomized order. The seed is the whole point: fix it and the same input list shuffles the same way every run; change it and you get a fresh order.
Inputs are list (any type) and seed (an INT, default 0). Output is the shuffled list, still a data list with items flowing downstream individually.
How it works
Mechanically it's Python's random.shuffle() on a copy of the list - your original isn't mutated, so re-runs behave predictably. The seed drives the shuffle, which means:
- Same list + same seed = same order, forever. That's how you debug a workflow that depends on a randomized ordering without the randomization moving underneath you.
- Change the seed and you get a genuinely different arrangement.
One real gotcha: this node calls the global random.seed(seed) before shuffling. That means it resets Python's global random state - if any other node in your workflow relies on the global RNG (some random value/seed nodes do), they can be affected by what you set here. It's an easy thing to miss and a hard thing to diagnose when your "random" outputs elsewhere suddenly stop varying. If that happens, this is the first node to suspect.
Where it fits
The classic uses: randomize the order you iterate through a batch of prompts, deal a random subset by shuffling then slicing, or pick a "random but reproducible" item by shuffling and taking the first with DataListFirst/last. If your goal is to remove one random item and keep the rest, the pack's pop random is the more direct tool - shuffle is for when you want the whole order scrambled.
Installing it
Part of StableLlama's Basic data handling pack - pure Python, zero dependencies, no model downloads:
cd ComfyUI/custom_nodes
git clone https://github.com/StableLlama/ComfyUI-basic_data_handling
Restart ComfyUI, or search "Basic data handling" in ComfyUI Manager. No requirements.txt conflicts because the pack ships with no third-party dependencies.
Common issues
The global-seed side effect is the one worth remembering - it's the difference between "my shuffle works" and "why did everything else in my workflow go deterministic?" Beyond that, the usual pack rules apply: feed it a data list, not a single LIST variable, and remember a fixed seed means a fixed result (set it, get the same order back; that's the feature).
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| list | * | — | |
| seed | INT | 0 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| list | * | — |