ComfyUI Node Runs on cloud

Text Sort

Alphabetize a list of lines inside the graph

By WASasquatch·Created 3 years ago·Updated a day ago· 1,839
Text Sort
    • STRING
    text
    separator,

    Straight up: this one isn't documented in WAS Node Suite's own README at all. It's absent from the pack's node list, which is otherwise fairly thorough - the README also hasn't been meaningfully updated since the author marked the pack retired in December 2023, so it's plausible this node landed after that list was last touched, or was simply never written up. What follows is a reasonable read of what a node named Text Sort, living inside WAS's text-utility family, does - not a quote from documentation, because there isn't one to quote.

    Given the name and its neighbors (Text List, Text Random Line, Text Load Line From File), the job is exactly what it sounds like: take a multi-line or list-style text input and return it sorted, most likely alphabetically, most likely with an ascending/descending option somewhere on the node.

    Where it'd actually be useful

    Anywhere you've got a list of text that arrived in an arbitrary or inconvenient order and you want it stable and readable before you do something with it. Feed it the keys you pulled with Text Dictionary Keys so a debug print comes out alphabetized instead of in whatever order the dictionary happened to store them. Sort a batch of loaded filenames before feeding them into a sequential loop. Clean up a wildcard file's lines for easier scanning. None of these are dramatic use cases - this is a tidiness node, not a creative one.

    How it works

    Best guess, grounded in how every text-sort utility of this shape works: it takes the text as a list of lines (or a delimiter-separated list), applies a standard sort, and returns the result as text in the new order. If it follows the pattern of similar utilities, sorting is lexicographic (character-by-character) rather than numeric - which matters if your lines are numbers, since lexicographic sort puts "10" before "2". That's a general property of string sorting, not something specific to this node, but it's the kind of surprise that trips people up the first time they hit it.

    The inputs and outputs that matter

    A text input containing the list to sort, and a text output containing it sorted. I don't have a confirmed schema for exactly what widgets (direction, delimiter, case sensitivity) sit on this node, so don't take any specific field name here as gospel - treat this as the shape of the job, not a screenshot of the UI.

    How to install it

    Ships with WAS Node Suite, same as every other node in the pack.

    ComfyUI Manager: search "WAS Node Suite," install, restart. Manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/WASasquatch/was-node-suite-comfyui
    

    then install requirements.txt against your ComfyUI Python and restart. Pure text handling, nothing heavy.

    Common issues & troubleshooting

    Order looks "wrong" for numbers. If your list is numeric text, lexicographic sorting will put "100" ahead of "20". That's expected behavior for a string sort, not a bug - if you need true numeric order, convert through one of WAS's Number nodes first.

    Case sensitivity surprises. Most string sorts treat uppercase and lowercase differently by default (capital letters typically sort before lowercase), which can put "Zebra" ahead of "apple". Worth checking if your sorted list looks oddly grouped.

    Whole pack won't import. Not this node's fault - WAS Node Suite has been unmaintained since December 2023, and a ComfyUI update can desync its pinned dependencies, throwing "Import Failed" across every node in the suite at once. Reinstall requirements.txt against the correct, activated Python environment and restart.

    CategoryWAS Suite/Text/Operations

    Inputs (2)

    NameTypeDefaultDescription
    textSTRINGList on one line; STRING. Sorted alphabetically and rejoined with separator. Leading brackets and weights are ignored. Eg: `sunset, cat, forest`
    separatorSTRING, The character the text is cut apart on, and the string the sorted terms are rejoined with. The default ', ' sorts a comma-separated prompt and puts a comma and a space back between each term.

    Outputs (1)

    NameTypeDescription
    STRINGSTRINGThe terms in alphabetical order, rejoined with the separator. Leading parentheses are ignored while sorting, so '((sunset))' files under s.