Class SortExecutor
java.lang.Object
ai.nervemind.app.executor.SortExecutor
- All Implemented Interfaces:
NodeExecutor
Executor for the "sort" node type - sorts items in an array.
/**
Executor for sorting arrays based on specified criteria.
Supports sorting by number, date, and string values with ascending/descending
order.
Orders array elements based on configurable criteria including sort field, direction, and data type. Supports auto-detection of value types for intelligent sorting behavior.
Node Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| inputField | String | "items" | Field containing the array to sort |
| outputField | String | "sorted" | Field to store sorted results |
| sortBy | String | null | Field path within each item (null = sort by item value) |
| direction | String | "asc" | "asc" for ascending, "desc" for descending |
| sortType | String | auto | "string", "number", or "date" (auto-detects if not specified) |
| nullsFirst | Boolean | false | true to put null values first |
Sort Types
- number - Numeric comparison (parses strings to double)
- string - Case-insensitive alphabetical comparison
- date - ISO date format comparison (YYYY-MM-DD)
- auto - Detects type based on actual values
Output Data
| Key | Type | Description |
|---|---|---|
| [outputField] | List | Sorted array |
| _sortedCount | Integer | Number of items sorted |
| _sortedBy | String | Field used for sorting |
| _sortDirection | String | "asc" or "desc" |
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionexecute(ai.nervemind.common.domain.Node node, Map<String, Object> input, ExecutionService.ExecutionContext context) Executes the business logic for this node type.Unique identifier for the node type this executor handles.
-
Constructor Details
-
SortExecutor
public SortExecutor()Default constructor for Spring.
-
-
Method Details
-
execute
public Map<String,Object> execute(ai.nervemind.common.domain.Node node, Map<String, Object> input, ExecutionService.ExecutionContext context) Description copied from interface:NodeExecutorExecutes the business logic for this node type.- Specified by:
executein interfaceNodeExecutor- Parameters:
node- The node definition containing parameters and configuration. UseNode.parameters()to access user settings.input- Combined output from all upstream nodes that connected to this node. For simple flows, this contains the direct predecessor's output. For merge nodes, it contains combined data.context- Verification context providing access to workflow-scoped services, logger, and execution metadata.- Returns:
- A Map containing the results of this node's execution.
Keys in this map become available variables for downstream nodes.
Note: Returningnullis treated as an empty map.
-
getNodeType
Description copied from interface:NodeExecutorUnique identifier for the node type this executor handles. This must match the 'type' field in the JSON definition of the node.- Specified by:
getNodeTypein interfaceNodeExecutor- Returns:
- The unique type string (e.g., "httpRequest", "llmChat").
-