Nodes/comfyui-huyl2-nodes/Sort List String
ComfyUI Node

Sort List String

The node that gives this whole pack its name

By huyl3-cpu·Created 9 months ago·Updated 4 months ago· 1
Sort List String
    • sorted_list
    list_string
    sort_methodnumeric
    sort_ascendingtrue

    comfyui-sortlist is the pack's repo name, and this is almost certainly why: a dedicated node for sorting a list of strings, with seven different ways to define "sorted." It's the kind of unglamorous glue you don't think about until a batch pipeline hands you files in the wrong order - file10.mp4 sorting before file2.mp4 because a plain alphabetical sort doesn't know those are numbers - and then it's exactly the node you need.

    How it works

    Feed it a string list and pick a sort_method. It reorders and hands back a sorted string, honoring a sort_ascending toggle for direction. The seven methods available:

    • default - whatever the list's natural/incoming order resolves to.
    • filename - sorts by just the basename, ignoring any directory portion.
    • parent_folder - sorts by the name of the containing directory.
    • full_path - plain sort on the entire string, path and all.
    • numeric - extracts and sorts by embedded numbers, so file2 correctly lands before file10. This is the default method, which tells you it's the one the author reaches for most.
    • date - presumably sorts by a date, though the schema doesn't specify whether that's filesystem modification time or a date pattern parsed out of the filename itself. Worth confirming on a small test list before trusting it on something that matters.
    • random - shuffles.

    The inputs and outputs that matter

    • list_string - the STRING list to sort. Required, no default.
    • sort_method - enum, seven choices as above, default numeric.
    • sort_ascending - BOOLEAN, default true. Flip it for descending order.

    Output: sorted_list (STRING).

    Where it fits

    This is connective tissue, not a destination node - it earns its place feeding whatever comes next. Pair it with video_dir_combiner's video_list input when your source folder's natural listing order doesn't match your intended combine order, or with VHS_VideoPickMinFrames' valid_paths when you want a predictable order before comparing frame counts across a batch. Anywhere a folder listing needs to go in a specific order before the rest of the graph touches it, this is the node to put first.

    Installing it

    ComfyUI Manager: search comfyui-huyl2-nodes, install, restart. By hand:

    cd ComfyUI/custom_nodes
    git clone https://github.com/huyl3-cpu/comfyui-sortlist
    

    restart ComfyUI. This node isn't mentioned in the pack's own README (which documents one unrelated video-cutting node), and it's pure string manipulation - no external dependencies, no models, nothing to download.

    Common issues & troubleshooting

    The date sort method is the one gap in an otherwise self-explanatory node: there's no tooltip or documentation clarifying its actual sort key. If your files carry dates in their names, run a quick test with a handful of known-order files before relying on it in a real batch - if it turns out to use filesystem mtime instead, that behaves very differently once files get copied or re-touched.

    Beyond that, the failure mode to watch for is upstream, not in this node: if list_string isn't actually a proper list by the time it reaches here (a single concatenated string instead of separate items, say), no sort method will save you - check whatever produced the list (StringConcatMulti or SplitMP3V2's file_paths, for instance) is genuinely emitting a list-typed output, not a single blob of text.

    Categorycustom/sortlist

    Inputs (3)

    NameTypeDefaultDescription
    list_stringSTRING
    sort_methodCOMBOnumeric7 options: default, filename, parent_folder, full_path, numeric, date, +1
    sort_ascendingBOOLEANtrue

    Outputs (1)

    NameTypeDescription
    sorted_listSTRING