Nodes/WAS Node Suite v3/Text List Sort
ComfyUI Node Runs on cloud

Text List Sort

Put the entries of a text list in order: alphabetical, natural so img2 comes before img10, by length, or shuffled by a seed, optionally dropping repeats and blank entries. Names wired beside the texts, such as file names, move with their texts.

By WASasquatch·Created 4 years ago·Updated 3 days ago· 1,900
Text List Sort
  • texts
  • names
  • texts
  • names
  • text
  • name
  • count
  • removed
◄order▾►
◄seed0►
◄dedupefalse►
◄ignore_casetrue►
◄drop_emptyfalse►
CategoryWAS Suite/Text/List

Inputs (7)

NameTypeDefaultDescription
textsARRAY,STRINGThe entries to order: a LIST, such as Text Split to List's, or a STRING list, such as the captions Load Text Batch reads.
orderCOMBO`as given` = unchanged; `a-z` / `z-a` = alphabetical; `natural` = digits read as numbers, img2 before img10; `shortest first` / `longest first` = by length; `shuffle` = random, set by seed.
seedINT00–18446744073709550000The shuffle's seed: the same seed and list always give the same order; another seed gives another. Read only by order `shuffle`.
dedupeBOOLEANfalseOn = an entry repeating an earlier one is dropped, the first kept, so `a cat` and ` a cat ` leave one; off = repeats stay.
ignore_caseBOOLEANtrueOn = `Cat` and `cat` sort together and count as repeats for dedupe; off = capitals sort before lower case and differ.
drop_emptyBOOLEANfalseOn = an entry holding nothing or only spaces is dropped, so 3 captions with 1 blank give 2; off = blanks stay in place.
namesoptARRAY,STRINGOptional names running beside texts, one per text, as the filename_list from Load Image Batch. Each moves and drops with its text. Another count than texts stops the run.

Outputs (6)

NameTypeDescription
textsARRAYThe entries in their new order, on one wire for Text List Get, Text List to Text and the other list nodes.
namesARRAYThe names in the same order as texts. Empty when names is not wired.
textSTRINGThe entries in their new order as a STRING list, so a node reading it runs once per entry. An empty list stops the nodes reading it.
nameSTRINGThe names as a STRING list, in step with text. Stops the nodes reading it when names is not wired or the list is empty.
countINTHow many entries came out.
removedINTHow many entries dedupe and drop_empty took out. 0 = every entry came through.