8/3/95 SORTX 2.0 ========= by Warren S. Macchi macchi@cs.ucf.edu SORTX is an enhancement to the sort program distributed with DOS operating systems. It has the same functions as the normal sort, plus some additional capabilities. This document has two sections. The first part introduces the operation of the DOS sort program in a simple and short manner. The second part details the characteristics of the SORTX program, which is an enhancement of the DOS version. If you are familiar with the operations of the DOS sort version, you may want to skip part one. PART 1: ------ The sort distributed with DOS (2.0 and up) is a simple to use sorting program that reads ASCII character lines from the standard input, sorts the lines in increasing or decreasing order, and outputs the sorted lines to the standard output. The lines are sorted without regard to upper or lower case letters. In addition, lines can be sorted beginning at a particular column specified in the command line. The following explanations assume that you have a path to the DOS files directory, or that you are in the directory that contains these files. A sample use of the DOS sort program is: sort /+8 sorted.doc where the input is taken from the "unsorted.doc" file, the output goes to the file "sorted.doc", and the sorting is accomplished starting at column 8 (specified by the /+8 switch). A reverse sort can easily be done by including the /r switch. As you can see, sorting of text lines is an easy task. Some uses of this program are encountered while programming in high level languages like BASIC, C, or PASCAL. The program invokes a shell to the DOS operating system with the name of the file to be sorted in place of "unsorted.doc," and the output filename in place of "sorted.doc." Typical users of the sort program are addresses, dictionaries, and other databases. You can see how sort works by just typing "sort"+ENTER. The program is now waiting for input from standard in, which is the keyboard. Just type in some lines with names or other data, then press the F6 function key (or CTRL-Z) plus ENTER, and the input is displayed in sorted order. That easy!! PART 2: ------ The DOS version of sort has some rather limited capabilities. Input data is restricted to no more than 64K, and line lengths are restricted to about 130 characters. This means that a database with data above these limits can not be processed with the DOS sort. In addition, a file with many lines may take a long time to sort. SORTX comes to the rescue by increasing the number of lines accepted to 30000, line lengths of up to 5000 characters, a fast sorting algorithm, and less memory requirements for small files. Input data is only restricted by available conventional memory and the line lengths and number of lines limits specified above. SORTX has the same command line parameters as the regular sort version, plus some more. The following is a list of them: /h or /? displays a list of available switches and current configuration /r produces a reverse sorting order /+nn sorts data starting at column "nn" /c case sensitive sort /l converts all input to lower case /u converts all input to upper case /d deletes duplicate lines /i specifies input file (instead of stdin) /o specifies output file (instead of stdout) /x outputs data in Unix format /p prints data statistics to stdout /s skips sorting of data /- inhibits output of sorted data The /p and /- options are useful when only an idea of the size and characteristics of the input file is needed. It is also useful for giving an idea of the time required to process a particular file, without displaying it. You can rename SORTX.EXE to SORT.EXE, so that programs that look for SORT.EXE can use the extended capabilities of SORTX. Note also that SORTX can be used to process all sorts of text files in order to change them to lower or uppercase, change text to DOS or Unix format, etc. by an appropriate use of the command line options. Running on a 286-16Mhz machine, SORTX can sort 15000 lines of data in about 22 seconds! This is achieved by the use of a fast heapsort algorithm. Information about heapsort can be obtained in many computer science books. If you are interested in getting a copy of the source file, you can ask me to e-mail it, or mail it to you, at the e-mail address in the heading. Hopefully you will appreciate the improvements that SORTX gives to the sorting of data. If this is the case, or if you have ideas for new features that you would like it to have, please let me know. SORTX is freely distributable, but please include all the files with it (SORTX.EXE and SORTX.TXT). Thank you for using SORTX!! Disclaimer: This program is provided as is, without warranty of any kind. The author shall not be liable for any damages caused by the use of this program. Use of this software indicates you agree to this.