sort — \windows\system32\sort.exe


Sort text or the contents of text files in alphanumeric order.


sort [/r] [/+n] [/m kilobytes] [/l locale] [/rec recordbytes]
    [/t [tempdir]] [/o outputfilename] [filename]


The sort command sorts text on a line-by-line basis. Each line of the input is ordered alphanumerically and output to the screen (or optionally, stored in a file). By default, sorting starts with the character in the first column of each line, but this can be changed with the /+n option. sort is often used in conjunction with either pipes or output redirection (both discussed earlier in this chapter). That is, you might want to sort the output of another command, and you will often want to redirect the output to a file so that it can be saved. sort takes the following options:


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

/+ n

Sorts the file according to characters in column n.

/m kilobytes

Specifies amount of main memory to allocate for the sort operation in kilobytes. The default is 90 percent of available memory if both the input and output are files, and 45 percent of memory otherwise. The minimum amount of memory sort will use is 160 Kb; if the available (or specified) memory is insufficient, sort will split the operation up using temporary files.

/l locale

Overrides the system default locale (see Control Panel Regional and Language Options). The “C” locale yields the fastest collating sequence, and in Windows XP, is ...

Get Windows XP in a Nutshell now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.