sort

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 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.

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