_.sort
Sort the values, keep the keys out of it
- obj
- *
_.sort sorts a collection and returns a new ordered copy. The subtle part is in the name and the description: this is sort the object's values - for a dict, you get a list of the values sorted, not a dict with sorted keys. For a plain list, it's just ascending order, plain and simple.
It comes from the comfy-ovum ovum/underscore family, auto-generated wrappers around underscore3 (a Python port of Underscore.js bundled inside the pack). The implementation calls Python's sorted(), which means it's stable (equal elements keep their relative order) and it never mutates your input - the wrapper deep-copies before wrapping. That last bit is the part worth caring about: sort-in-place is a classic source of cross-branch corruption in Comfy graphs, and this node sidesteps it entirely.
When you'd reach for it
Sorting shows up in all sorts of glue-code places: ordering a list of filenames before passing them to a batch process, sorting prompt variants so you process them in a predictable order, or sorting a list of scores before taking the top n with _.take. If the sort key is just the values themselves, _.sort is the one.
If you need to sort by a criterion - by a property, by length, by a computed key - that's _.sortBy in the same menu, which exposes an iteratee. And if you specifically want a dict's values sorted while keeping the dict shape, _.sortObjectBy is the family's other twist. _.sort is the plain one.
Inputs and output
- obj (
*) - the collection. Lists and tuples sort naturally; dicts sort by their values (the_values()path), which is the behavior the description is describing.
Output is a single * socket carrying the sorted result. Because the return type is generic, Comfy won't enforce list-ness downstream - wire it into a list consumer.
Standard family behavior: pass a _.CHAIN in as obj and it continues the chain, returning a chain you unwrap with _.value. Handy for _.chain → _.sort → _.first → _.value ("lowest value") style pipelines.
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.) via Manager, underscore3 bundled. The author's README labels the underscore family a work in progress - fair warning, and the reason I'd point you to _.sortBy over _.sort if you have even a whiff of a criterion in mind, because that node's input set is built out properly while this one stays bare.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| objopt | * | Primary input object. Also accepts _.CHAIN to continue chaining. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| * | * | — |