Version 0.2.3 behavior is documented here. Thesupport record separates local verification frompublished MoonX behavior; moonx examples use registry releases.
Options include -r, -u, -b, -d, -f, and -i, plus -n numeric,-g general numeric, -h human numeric, -M month, and -V versioncomparisons. Repeated -k F[.C][OPTS][,F[.C][OPTS]] keys support field,character, and local comparison modifiers; -t BYTE selects a fieldseparator. -z selects NUL records. -c/--check diagnoses the first disorderand -C/--check=quiet only returns status 1.
Comparison uses C-locale byte rules without changing environment variables.Blank-separated fields retain their leading separator run unless -b applies;case folding maps lowercase ASCII to uppercase, and human numeric order comparessign, suffix magnitude, then numeric value. Key ties use the whole record as thelast resort and remaining ties retain input order. -s/--stable suppresses thatwhole-record fallback, preserving input order among equal keys. -u retainsthe first representative under the selected keys.
-R/--random-sort or --sort=random orders transformed keys byMD5(seed || effective key), comparing digest bytes and then key bytes on adigest collision. Equal keys remain together; ordinary record fallback, -s,-u, reverse ordering, and local key modifiers still apply. An effectiverandom key consumes exactly 16 bytes from --random-source=FILE before inputprocessing, even for empty input. Without a source, the public secure randomAPI supplies the seed. A source named - is a literal file. Repeated identicalsource paths are allowed; different source strings conflict. A source is notread when local key comparison modifiers suppress global random ordering.
-m/--merge merges already-sorted inputs without checking or repairing theirorder. Equal keys keep operand order and then source order with -s or -u.It shares the heap and temporary runs, including additional rounds when theselected merge fan-in is exceeded.
-o/--output=FILE writes to a named file with empty stdout; -o - names aliteral file. Ordinary sorting consumes all input before truncating the output,so existing outputs and input aliases are supported. Missing inputs leave anoutput uncreated; a later read error can leave a newly created output emptywhile retaining an existing output's bytes. Check mode conflicts with output.Repeated identical output strings are allowed and distinct strings conflict.
Merge accepts new output files. Merge into an existing output is rejectedwithout mutation: the released filesystem API has no opened-file identity ordescriptor truncation with which to protect aliased merge inputs. Lifting thisboundary requires those public APIs and alias/error-effect regressions.For named merge output, all inputs are consumed into temporary runs beforethe output is opened for writing; an input failure can retain the empty filecreated by output preflight. Standard-output merges can emit earlier recordsbefore a later read failure.
Records and transformed keys are prepared once before comparison. Sorting usesa default 64 MiB accounted run budget and at most 16-way heap merges, with64 KiB input, output and merge buffers. Stable sequence IDs and prepared keyssurvive disk runs; -u keeps the first representative across run boundaries.Check mode retains only adjacent records. With no file operand, stdin is readuntil EOF.
-S SIZE/--buffer-size=SIZE selects the accounted sorting-data budget. A bareinteger uses KiB, b selects bytes, and K, M, G, T, P, E, Z,Y, R and Q select powers of 1024. Values must fit signed 64-bit byteaccounting; fractions and compound suffixes such as MiB reject. Zero and verysmall requests use the fixed-buffer minimum and still permit an oversizedrecord. Repeated sizes choose the largest, independent of option order.0% selects the same minimum as zero bytes. Other SIZE% values rejectexplicitly: released public MoonBit APIs do not expose physicalmemory totals. Supporting it requires that query, with percentage and overflowregressions; the command does not estimate memory through an external program.
-T DIR/--temporary-directory=DIR overrides the host temporary location andmay repeat. Runs rotate between invocation-owned children of those directories;the parent directories are not created or removed. Unused locations are notopened. --batch-size=N requires an integer of at least two and limits mergefan-in to the smaller of N and 16; its default is 16. Environment variables arenever changed to implement these controls.
Spilling requires the host to allow writes in its temporary directory. A deniedtemporary write exits 2 before sorted output is emitted, following GNU sort'sfatal-error status. Small in-memory sorts, check mode and standard-output mergeswithin the selected fan-in do not create disk runs; named merge output usestemporary runs even for small inputs.Under a Windows sandbox, the host must also provision TMP or TEMP fortemporary-path lookup; the command preserves the environment supplied by the host.
The run budget counts record/key payloads, entry/key slots, sequence IDs andreserved merge buffers/index space. Fixed buffers reserve(selected fan-in + 6) * 64 KiB; at least one record is accepted beyond thatminimum. It is not an RSS cap: the active inputrecord, unique-key retention, allocator/GC overhead and oversized individualrecords can add storage. Oversized records are processed without truncation.Temporary directories and files are created exclusively with restrictivepermissions and removed on normal completion or propagated errors; this doesnot promise cleanup after an unobservable crash or SIGKILL.
Standalone --version prints exactly sort 0.2.3 followed by onenewline. Standalone --help starts with Usage: sort, lists bothmetadata options, and ends with a newline. Both write to stdout, leave stdinunread, and exit with status 0. Exact-version publication and verificationremain recorded separately in the support record.