Microsoft KB Archive/70623

Sort Does Not Expand Tab Characters PSS ID Number: Q70623 Article last modified on 02-08-1993 PSS database name: O_MSDOS

4.01

MS-DOS

Question:

Sort does not appear to work properly when I attempt to sort a file containing tab characters by columns using the “Sort /+n” command. How does Sort deal with tabs?

Response:

Sort does not expand tab characters into spaces. Instead, Sort treats the tab as one character with an ASCII value of 9. This causes improper sorting of text containing tab characters.

Examples
A text file contains the following lines:

a b c c d c

When you sort the text with the /+1 option (default), the output is:

a b c c d c

a < b < c < d

When you sort the text with the /+2 option, the output is:

b c c a d c

+ < +c < <

When you sort with the /+3 option, the output is:

a ;line ignored b d c c c

< < c

When you sort by column /+4, the output is:

a ;line ignored b ;line ignored c c d c

<

When you sort by column n>5, the output is:

a ;line ignored b ;line ignored c c ;line ignored d c

Additional reference words: 4.01 noupd

Copyright Microsoft Corporation 1993.