_.max
The biggest value in a list — with an iteratee for 'biggest by some criterion'.
- list_or_dict
- iteratee
- *
_.max does what you'd expect - returns the biggest value in a list - but the interesting half is the optional iteratee, which turns it into "biggest by some criterion." Feed it a list of dicts and a key, and it returns the single item that scores highest on that key. That's a selection operation you'd otherwise build with a loop and a comparison, and here it's one node.
What it is
Part of the ovum/underscore family in sfinktah/comfy-ovum, wrapping the max method of underscore3, a Python port of Underscore.js. The iteratee is normalized through _.iteratee, so you get the full shorthand menu: a function, a key string, an object, or JSON. Plain call with no iteratee is just max(list) - numeric comparison across the elements.
Inputs that matter
list_or_dict(type*) - the collection to search.iteratee(type*, force-input) - the criterion: function, key string, or object shorthand.iteratee_json(STRING, multiline) - JSON or a key selector, used when the socket isn't connected. The save-friendly path.
Output is typed * (ANY) - the winning element itself. Chain mode works: feed a _.CHAIN and get a chain back, resolved with _.value.
The quirks the docs warn about
Three, and the port's own description lists them, so treat them as facts:
- Empty list →
-Infinity. NotNone, not an error. The description suggests guarding with anisEmptycheck if that matters to you. - Dict input →
[]. If you feed_.maxa dict, you get back an empty list rather than a meaningful max. Don't do that. - Numbers only, reliably. The description says it "can currently only compare numbers reliably." Strings may sort, but don't build production logic on mixed types.
Where you'd use it
Ranking and selection. Find the highest-scoring item in a list of dicts by setting iteratee_json to "score". Pick the longest filename by key "length". Choose the last/best seed. The key-selector form survives saves and reloads, which makes _.max one of the more durable members of the family - much more usable than its cousin _.maxBy, which has wiring problems covered on that node's page.
Installing comfy-ovum
ComfyUI Manager: search for comfy-ovum, install, restart. Or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/sfinktah/comfy-ovum
pip install -r comfy-ovum/requirements.txt
Restart and you're set. No model downloads, no CUDA - pure-Python utilities. Family caveat stands (work in progress), but with the key-selector path and a mental note about the empty-list behavior, _.max is genuinely usable.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| list_or_dictopt | * | Primary input object (expected collection). You can still pass any JSON-serializable value. Also accepts _.CHAIN to continue chaining. | |
| iterateeopt | * | iteratee: ANY input to override widget. Accepts function, key string, or object shorthand. | |
| iteratee_jsonopt | STRING | iteratee_json: JSON or key selector. Used when 'iteratee' input is not connected. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| * | * | — |