ComfyUI Node Runs on cloud

Reorder

Sort or reverse a sequence — and skip the one option that's currently broken

By ali1234·Created 3 years ago·Updated 3 months ago· 130
Reorder
  • sequence
  • sequence
methodsort

Once you've built a SEQUENCE with Range, Literal, or Combinations, you sometimes want it in a different order before you turn it into a job - sort a list of filenames alphabetically, or flip a numeric sweep so it counts down instead of up. That's the whole job of Reorder: it takes a sequence in, and hands the same values back rearranged.

How it works

It's three thin wrappers around plain Python: reverse calls reversed(), sort calls sorted(), and a third option is supposed to sort in descending order. Nothing fancier than that - no custom comparator, no key function, just whatever Python's default ordering does with your values.

The inputs and outputs that matter

  • sequence (SEQUENCE) - whatever you built upstream.
  • method - a three-way choice: reverse, sort, reverse sort.

Output is a single sequence, ready to feed into MakeJob, CombineJobs, GetJobStep, or another sequence node in the chain.

One thing worth flagging plainly: the "reverse sort" option is currently broken. Reading the pack's own source, the dropdown offers "reverse sort" with a space, but the lookup table that maps each choice to a function only defines a key with an underscore (reverse_sort). Pick "reverse sort" from the menu and the node throws immediately instead of doing anything useful. Until that gets fixed upstream, get the same result the honest way: run Reorder with sort, then feed that output into a second Reorder set to reverse.

How to install it

Via ComfyUI Manager: search comfyui-job-iterator, install, restart. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/ali1234/comfyui-job-iterator

then restart. No dependencies to install - this node uses nothing beyond the Python standard library.

Common issues & troubleshooting

"reverse sort" throws an error the moment you queue. That's the bug above, not something you did wrong. Chain two Reorder nodes (sort then reverse) instead.

Sorting mixed types errors out. Python's sorted() can't compare a string to a number, so if your sequence mixes types - say some items came out of Literal as strings and others as ints - sorting throws a TypeError. Keep the sequence's element types consistent before this node, or sort before you mix sequences together with CombineJobs.

Sorting doesn't do what you expect on tuples. If you're feeding in the output of a Combinations or Permutations node, each element is a tuple, and Python sorts tuples element-by-element (lexicographically) rather than by any single field. That's usually fine, but it's worth knowing if the resulting order looks odd - it's sorting the whole tuple, not just the first item in it.

Categoryali1234/sequence

Inputs (2)

NameTypeDefaultDescription
sequenceSEQUENCE
methodCOMBOsort3 options: reverse, sort, reverse sort

Outputs (1)

NameTypeDescription
sequenceSEQUENCE