sort

package
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 28, 2026 License: MIT Imports: 8 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Sort node

Type: sort
Category: Flow Control

Sorts a payload array or a message sequence.

Behavior

This node is registered as sort and runs as part of a workflow. Its exact runtime behavior is implemented in node.go; this document summarizes the editor-facing purpose and configuration contract.

Configuration

Field Type Default Description
as_num boolean false Numeric Compare — Coerce compared values to numbers first
msgKey string Element Key — msg target: per-element key — evaluated as a sequence expression when msgKeyType is "jsonata"
order string ascending Order
seqKey string Sequence Key — seq target: message path or sequence expression used as sort key (default "payload")
target string Target Property — msg target: message property holding the array to sort (default "payload")
targetType string msg Target — msg: sort the array at target in place; seq: sort a message sequence by seqKey

Implementation

  • node.go contains the executor, validation, schema, and registration.
  • editor.html contains the editor integration.
  • node_test.go, when present, contains behavioral tests.

Documentation

Overview

Package sort contains the sort node implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SortConfig

type SortConfig struct {
	// Order is "ascending" (default) or "descending" — the "asc"/"desc"
	// spellings from older serialization are also accepted
	Order string `json:"order"`
	// AsNum coerces compared values to numbers first (serialized "as_num")
	AsNum bool `json:"as_num"`
	// Target is the msg-target property path holding the array to
	// sort (default "payload"); ignored for seq target
	Target string `json:"target"`
	// TargetType selects the sort target: "msg" sorts the array at
	// Target in place, "seq" sorts a parts sequence by SeqKey
	TargetType string `json:"targetType"`
	// MsgKey is the msg-target element key: msgKeyType "jsonata"
	// evaluates it against each element, anything else compares the
	// elements themselves
	MsgKey string `json:"msgKey"`
	// MsgKeyType is "elem" (compare elements) or "jsonata"
	MsgKeyType string `json:"msgKeyType"`
	// SeqKey is the seq-target sort key: seqKeyType "msg" reads a
	// message property path, "jsonata" evaluates it against the message
	SeqKey string `json:"seqKey"`
	// SeqKeyType is "msg" or "jsonata"
	SeqKeyType string `json:"seqKeyType"`
}

SortConfig holds configuration for the sort node — the Node-RED sort equivalent (order/as_num/targetType/msgKey/seqKey fields).

type SortNode

type SortNode struct {
	*nodebase.BaseNode
	// contains filtered or unexported fields
}

SortNode sorts either a payload array in place ("msg" target) or a buffered parts sequence re-emitted in order ("seq" target).

func NewSortNode

func NewSortNode(node nodestore.NodeInterface, config *SortConfig, host nodebase.NodeHost) *SortNode

NewSortNode creates a new sort node

func (*SortNode) Execute

Execute sorts a payload array in place (msg target) or buffers a parts sequence until complete (seq target), re-emitting the sorted messages asynchronously in order and dropping the current one.

func (*SortNode) Validate

func (n *SortNode) Validate() error

Validate rejects unsupported target/order combinations

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL