BASIC-DOS

A PCjs Retro-Programming Project

BASIC-DOS is on Twitter Project maintained by jeffpar

BASIC-DOS Manual

SORT

SORT [/R] [/+n] [file]

A filter that displays the lines of input (or file) in sorted order, ignoring case (eg, DIR | SORT).

  • /R sorts in reverse order
  • /+n sorts on the characters starting at column n (eg, DIR | SORT /+10 sorts a directory listing by extension); the first column is 1, and a line that’s too short sorts as if it were empty

Lines that differ only in case, or that match from column n on, can be displayed in any order.

SORT NAMES.TXT
Four five
One
three
Two
Two

Up to 64K of text can be sorted, including 2 bytes for each line. If there’s more than that, or more than memory allows, SORT displays Not enough memory, and ERRORLEVEL is set to 1. ERRORLEVEL is set to 2 if file couldn’t be opened (eg, Unable to find X.TXT), and otherwise to 0.

Source: sort.asm

« SLEEPSYS »

Copyright (c) 2020-2026 Jeff Parsons Released under MIT License