Nodes/comfy-ovum/_.sortObjectBy
ComfyUI Node

_.sortObjectBy

Sort a dict's values, with a reverse switch

By sfinktah·Created about a year ago·Updated 10 months ago· 7
_.sortObjectBy
  • obj
  • reverse
  • *

_.sortObjectBy sorts an object's values by a criterion - think of it as "sort the contents of a dict, ranked by an iterator." It's the dict-flavored cousin of _.sortBy, and the description is almost word-for-word the same as _.sort's, which tells you something about how this family was generated: it's an addition in the underscore3 Python port, not a classic Underscore.js method, and the auto-generated docs blur the lines.

So what does it actually give you? Feed it a dict and you get the values back, ordered by whatever criterion the implementation applies, optionally reversed. It's a convenience node for when your data arrives as a keyed object and you care about the ordering of what's inside, not the keys themselves - e.g., a dict of score → value pairs you want best-first, or a dict of settings you want sorted before logging.

The honest caveat

This sits in the ovum/underscore family of comfy-ovum, which the author's own README calls a work in progress and "not recommended for use in workflows." And this node shows the family's generator limits more than most: its signature has an iteratee parameter, but because the generator only builds predicate/iteratee inputs for a hardcoded list of methods - and sortObjectBy isn't on it - the iteratee never gets exposed. Look at the actual node and you'll see just two inputs: obj and reverse. So you get sorting and a reverse toggle, but no way to specify what to sort by. If that's all you need, great. If you need a real criterion, _.sortBy (which exposes its iteratee properly) is the node you actually want.

Inputs and output

  • obj (*) - the dict (or any object) whose values get sorted.
  • reverse (*) - a JSON-typed input (the tooltip notes JSON is allowed) that flips the order when truthy. Expect a boolean-style value here.

Output is a single * socket carrying the sorted values as a list. Standard family behavior: pass a _.CHAIN in as obj and it keeps the chain alive, returning a chain to unwrap with _.value.

Install

# via ComfyUI Manager: search "comfy-ovum"
cd ComfyUI/custom_nodes
git clone https://github.com/sfinktah/comfy-ovum
# restart ComfyUI

No model downloads; pure Python, deps (aiohttp, pillow, numpy, requests, etc.) installed by Manager, underscore3 bundled in the repo. If a workflow you've grabbed from the wild includes _.sortObjectBy and the ordering looks wrong, check the reverse input first - it's the only dial you've got, and it's easy to flip accidentally when you're wiring from a shared constant.

Categoryovum/underscore

Inputs (2)

NameTypeDefaultDescription
objopt*Primary input object. Also accepts _.CHAIN to continue chaining.
reverseopt*reverse: JSON allowed for arrays/objects where applicable.

Outputs (1)

NameTypeDescription
**