Quincy Center for Technical Education
Computer Technology Department

Sort

Reads input, sorts data, and writes the results to the screen, to a file, or to another device.

sort [/r] [/+n] [/m kilobytes] [/l locale] [/rec characters] [[drive1:][path1]filename1] [/t [drive2:][path2]] [/o [drive3:][path3]filename3]

[command |] sort [/r] [/+n] [/m kilobytes] [/l locale] [/rec characters] [[drive1:][path1]filename1] [/t [drive2:][path2]] [/o [drive3:][path3]filename3]

Parameters

/r

Reverses the sort order; that is, sorts from Z to A, and then from 9 to 0.

/+n

Specifies the character position number, n, at which sort begins each comparison. For example, /+3 indicates that each comparison should begin at the third character in each line. Lines with fewer than n characters collate before other lines. By default, comparisons start at the first character in each line.

/m kilobytes

Specifies the amount of main memory to use for the sort, in kilobytes (KB). The memory used is always a minimum of 160 KB. If the memory size is specified, the exact specified amount (but at least 160 KB) is used for the sort, regardless of how much main memory is available.

The default maximum memory size when no size is specified is 90 percent of available main memory if both the input and output are files, and 45 percent of main memory otherwise. The default setting usually gives the best performance.

/l locale

Overrides the sort order of characters defined by the system default locale; that is, the language and Country/Region selected when Windows 2000 was installed. Currently, the only alternative to the default locale is the "C" locale, which is faster than natural language sorting and sorts characters according to their binary encodings.

/rec characters

Specifies the maximum number of characters in a record, or a line of the input file (the default is 4,096, and the maximum is 65,535).

[drive1:][path1]filename1

Specifies the file to be sorted. If no file name is specified, the standard input is sorted. Specifying the input file is faster than redirecting the same file as standard input.

/t [drive2:][path2]

Specifies the path of the directory to hold the sort command's working storage, in case the data does not fit in main memory. The default is to use the system temporary directory.

/o [drive3:][path3]filename3

Specifies the file where the sorted input is to be stored. If not specified, the data is written to the standard output. Specifying the output file is faster than redirecting standard output to the same file.