API · Aggregate

sort()

Buffer the complete stream and emit its values in ascending string order.

Signature

sort(): Exstream<T, C>

Example

exstream([10, 2, 1]).sort().valuesSync()
// [1, 10, 2]

Ordering

Values are compared using String(value) and ascending code-unit order, not numeric order. undefined is always placed after defined values. Sorting is stable when values compare equally. Symbols cannot be converted by this operator and cause a record error for the collected input. Use sortBy() for numeric, locale-aware, or field ordering.

Memory and pressure

sort() retains every successful value and its context until upstream ends, then emits the sorted sequence. No output appears early, so it cannot operate on an infinite source. During final emission, downstream buffering and pressure rules still apply. Existing record errors pass through immediately and are not sorted.

Forms

stream.sort()
exstream.pipeline().sort()
exstream.sort(stream)

sortBy(), sortedGroupBy(), collect()