# List Toolkit

Perform one list operation (sort, dedup, filter, map, reduce, merge, slice, find, index of or contains) on a JSON array without chaining Evaluate Expression steps.

Type: reference · Mode: develop

---
Perform one list operation (sort, dedup, filter, map, reduce, merge, slice, find, index of or contains) on a JSON array without chaining Evaluate Expression steps.

**Step library location:** Logic

## Operations

- **Sort:** Sorts the list in Sort Order. For a list of objects, Sort By Field names the field to sort on. If every value is a number, or text that reads as one, the sort is numeric; otherwise it is alphabetical and case-sensitive. Items without the field go last.
- **Dedup:** Removes duplicates and keeps the first occurrence of each value. Objects with the same fields and values, in any order, count as duplicates.
- **Filter:** Keeps the items for which Expression is true, for example `item.age > 30`.
- **Map:** Replaces each item with the result of Expression, for example `item.name` or `item.price * 1.13`.
- **Reduce:** Combines the list into one value. Initial Value is the starting value of `acc`, and Expression returns its new value for each item, for example `acc + item.amount`.
- **Find:** Returns the first item for which Expression is true, or empty text (`""`) if nothing matches.
- **Merge:** Adds Second List to the end of Input List. Duplicates are kept.
- **Slice:** Returns the items from Start Index (included) up to End Index (not included).
- **Index Of:** Returns the 0-based position of the first item equal to Search Value, or `-1` if there is none.
- **Contains:** Returns `true` if any item equals Search Value and `false` otherwise.

## When to use it

- Filtering or reshaping a list returned by an API before you loop over it.
- Totalling a list of values, such as invoice amounts, with Reduce.
- Checking whether a value is in a list, or finding where it is.

## Input Configuration

<div class="sym-spec-table">

| Field | Type | Need | Default | Notes |
| --- | --- | --- | --- | --- |
| **Operation** | Dropdown Selector | Required | Sort | String (enum). Options: Sort, Dedup, Filter, Map, Reduce, Merge, Slice, Find, Index Of, Contains |
| **Input List** | Auto-complete param expression field | Optional | None | JSON array. Shown for every operation. Must be a JSON array. Blank is treated as an empty list. |
| **Second List** | Auto-complete param expression field | Optional | None | JSON array. Shown for Merge. Must be a JSON array. It is added after Input List, and duplicates are kept. |
| **Expression** | Auto-complete param expression field | Optional | None | String (JavaScript expression). Shown for Filter, Map, Reduce and Find. Use `item`, `index` and, for Reduce, `acc`. Reference Process parameters with @. |
| **Initial Value** | Auto-complete param expression field | Optional | None | JSON value. Shown for Reduce. The starting value of `acc`, written as JSON such as `0`, `""`, `[]` or `{}`. A value that isn't valid JSON is kept as text. |
| **Sort By Field** | Static input field | Optional | None | String. Shown for Sort. For a list of objects, the field to sort by, for example `age`. Blank sorts the values themselves. |
| **Sort Order** | Dropdown Selector | Optional | Ascending | String (enum). Options: Ascending, Descending. Shown for Sort. |
| **Start Index** | Static input field | Optional | None | Integer. Shown for Slice, and required there. 0-based and included. A value outside the list, including a negative one, moves to the nearest end. |
| **End Index** | Static input field | Optional | None | Integer. Shown for Slice. 0-based and not included. Blank reads to the end. An End Index before the Start Index returns `[]`. |
| **Search Value** | Auto-complete param expression field | Optional | None | JSON value. Shown for Index Of and Contains. Compared as JSON, so `5` matches the number 5 and `"5"` matches the text "5". Key order in objects is ignored. |
| **Max Items** | Static input field | Optional | 1000 | Integer. Shown for Filter, Map, Reduce and Find, which fail if the list has more items than this. Must be 1 or more. The other operations have no item limit. |

</div>

## Output Configuration

<div class="sym-spec-table">

| Field | Type | Need | Default | Notes |
| --- | --- | --- | --- | --- |
| **Output Parameter: Result** | Static/Dynamic Parameter Field | Required | ListResult | String. Sort, Dedup, Filter, Map, Merge and Slice store a JSON array, Reduce the final value, Find the matching item, Index Of a number and Contains `true` or `false`. |

</div>

## Notes

Choose an Operation and set Input List to a JSON array such as `[3,1,2]` or `[{"name":"Ana","age":34}]`. The step then shows only the other fields that operation needs.

Expressions (Filter, Map, Reduce and Find) are JavaScript. Use `item` for the current item, `index` for its 0-based position and, in Reduce, `acc` for the running value. Reference Process parameters with @.

Example: an API returns a list of invoices. Filter it with `item.status == "OPEN"`, then Reduce the result with an Initial Value of `0` and the Expression `acc + item.total` to get the customer's open balance.

<p class="sym-generated-note">Generated from step metadata (<code>src/data/process-steps.json</code>). Edit the metadata, not this page.</p>