Class SortExecutor

java.lang.Object
ai.nervemind.app.executor.SortExecutor
All Implemented Interfaces:
NodeExecutor

@Component public class SortExecutor extends Object implements NodeExecutor
Executor for the "sort" node type - sorts items in an array.

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

Sort node configuration 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

Output keys added by this executor
Key Type Description
[outputField] List Sorted array
_sortedCount Integer Number of items sorted
_sortedBy String Field used for sorting
_sortDirection String "asc" or "desc"
/** Executor for sorting arrays based on specified criteria. Supports sorting by number, date, and string values with ascending/descending order.
See Also:
  • 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: NodeExecutor
      Executes the business logic for this node type.
      Specified by:
      execute in interface NodeExecutor
      Parameters:
      node - The node definition containing parameters and configuration. Use Node.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: Returning null is treated as an empty map.
    • getNodeType

      public String getNodeType()
      Description copied from interface: NodeExecutor
      Unique identifier for the node type this executor handles. This must match the 'type' field in the JSON definition of the node.
      Specified by:
      getNodeType in interface NodeExecutor
      Returns:
      The unique type string (e.g., "httpRequest", "llmChat").