文本排序验证
Does your cast show up in the order you promised?
- text
Here's a small node with an oddly specific job: you give it a block of text and a list of things you expect to find in it, and it returns those things sorted by where they actually first appear - dropping anything that doesn't appear at all.
What that's for
The obvious use is verification. You wrote a shot list, or generated one, and you want to confirm the cast enters in the order the scene requires. Run the text through this node with the character names as 验证对象, and read the output: if it comes back 陈默,林昭,旧城 you're in order; if the answer contains only two of three names, the third isn't in the text at all and you just found a continuity bug at zero cost.
The non-obvious use, and the more useful one, is canonicalising a subject list. Diffusion models are order-sensitive - putting the subject first biases the composition toward it. If you maintain a list of elements you want in a generation, this node can reorder that list to match the sequence they appear in a reference text, which is a cheap way of letting a script dictate composition order without hand-maintaining two lists that have to agree.
The mechanics, which are three statements
验证对象 is multiline, one object per line. Lines are stripped, empties dropped, and duplicates removed keeping the first occurrence. Then each object's position is looked up in text with a plain substring search, objects that aren't found are discarded, what's left is sorted by position, and the survivors are joined with 分隔符 (default ,).
The output is that single joined STRING, ready for a CLIP text encode or another text node.
That's the whole node. No outputs for the missing items, no annotations, no error. Which is the design: a "verification" node that screams when something is absent would be a graph-breaker, and this one is meant to sit inline in a working pipeline.
The traps, all of which come from substring matching
It matches substrings, not words. An object Ana will match inside Anastasia, and 小明 matches inside 小明明. If your terms are prefixes or suffixes of each other, positions will be wrong and you'll have no idea why. Order your validation list carefully, or make the terms unambiguous.
Only the first occurrence counts. Repeat a name in paragraph five and it doesn't matter - the node sorts by where each object first shows up.
Missing objects vanish silently. That's half the point (the absence is the signal), but it means a typo in your object list looks identical to the object genuinely not being in the text. If you gave it 小明 and the text says 小名, you'll see the term missing and assume the text is wrong.
No case folding, no normalisation. Case, full-width versus half-width characters, and trailing spaces all matter. Strip and standardise upstream if you're comparing machine-generated text against hand-written terms.
Also worth knowing what this node is not: it doesn't sort a text block's lines, and it doesn't number anything. If you want lines numbered in order, that's 列表编号 in the same pack. This one sorts a list you provide by its apparent position in a text you provide - a lookup, not a formatter.
Install
Part of yanhuo-easy-use, the 16-node utility pack: category yanhuo, Chinese node labels, MIT, v1.3.1. ComfyUI Manager → search the pack title → install → restart. Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/yanhuoxunxianren/yanhuo-easy-use
# restart ComfyUI
No pip install - the pack's pyproject.toml declares an empty dependency list - and no models to download. The node is pure string work, CPU-only, instant.
Common issues
"The output is empty." Either text was empty, or none of your objects appear in it. The node returns an empty string for both cases; it can't tell you which. Check your object list for a typo before you assume the text is missing the term.
"My order looks right but it's not what I expected." Verify the object list against the text by hand once, with substring thinking: if two terms overlap, the shorter one's position may come from inside the longer one's occurrence.
"The separator came out wrong." Misleadingly, 分隔符 sits in the required group and looks like a widget you might leave alone - but if you typed a , with a trailing space, you get that space in the output too. Which is sometimes what you want for a prompt.
"I want it to complain when something's missing." It won't. Compare the output against your object list yourself, or feed the result into a second node that counts.
"Can it sort comma-separated input in one field?" The object list is newline-separated, one per line. A single line with commas is treated as one very long object name - a common first-hour mistake, because the output field is comma-separated and it looks symmetrical.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| text | STRING | 输入要检查的原始文本。 | |
| 验证对象 | STRING | 需要验证的对象列表,每行一个。 | |
| 分隔符 | STRING | , | 输出排序结果时使用的分隔符。 |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| text | STRING | — |