home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / bgsort.zip / bigsort.txt < prev   
Text File  |  1993-03-16  |  11KB  |  284 lines

  1.        BIGSORT V4.1: A Fast in-memory sort for files of any size.
  2.           ----------------------------------------------------
  3.                          User Supported Program
  4.                 Continued use requires a donation of $20
  5.  
  6.  
  7. (C)1988-93 Turgut Kalfaoglu <turgut@frors12.bitnet>,<turgut@frmop11.bitnet>
  8.  
  9.  
  10. BIGSORT uses the fastest known sorting algorithm to sort files that can 
  11. be as large as your swapping area (not RAM) allows. A wide range of 
  12. options along with multiple key fields enable you to pinpoint the 
  13. desired sorting method.
  14.  
  15. BIGSORT is especially well suited for batch files, and to be called from 
  16. other programs. It returns specific error codes, and never prompts for 
  17. verification or additional information. Always using the defined 
  18. (primary) collating sequence for your country, BIGSORT will be able to 
  19. place your national characters in the correct order.
  20.  
  21. Unless /Verbose option is specified, BIGSORT never writes its messages 
  22. to the standard output, to prevent its messages from getting written to 
  23. an output file. Its messages are always directed to "standard error." 
  24. Under OS/2, it is possible to redirect stderr to a file, if desired.
  25.  
  26. This program is shareware: A registration allows you stay up-to-date on 
  27. enhancements to the product, and enables you to purchase the source 
  28. code.
  29.  
  30.  
  31. Usage:
  32.  
  33. BIGSORT [options] < inputfile > outputfile
  34.  
  35. if you omit the '< inputfile' part, BIGSORT will wait for an answer from 
  36. the keyboard. If that is what you wish, enter the data, separating each 
  37. one by a RETURN character, then enter CTRL-Z to finish the entry.
  38.  
  39. if you omit '> outputfile' part, BIGSORT will send its output to the 
  40. screen.
  41.  
  42. For some online help, type
  43.       BIGSORT HELP
  44.  
  45.  
  46. The normal usage of BIGSORT is either thru OS/2 "pipes", or thru 
  47. redirection. Pipes enable a program's output to be sent as input to a 
  48. second program. This is specified by using the "|" symbol between the 
  49. two programs. Redirection is similar, it allows the output of a command 
  50. to be sent to a file, instead of getting displayed on the screen. The 
  51. ">" symbol indicates that the output should be sent to the file, not to 
  52. the screen. Note that the > symbol causes the previous contents of the 
  53. file to be lost. The >> symbol can be used to append to the previous 
  54. contents. 
  55.  
  56.  
  57.  
  58. Options
  59. -------
  60.  
  61.     Use options to change the default behavior of BIGSORT, which is:
  62.         * Start sorting on the first position of each line,
  63.         * Do a case-sensitive alphanumeric sort,
  64.         * Reserve room for 100,000 lines of input file. (Lines, not 
  65.           bytes).
  66.  
  67.     If you wish to use multiple options, you need to separate them by 
  68. spaces. The options available with this version are:
  69.   
  70.   /+nnn   where nnn's are a number, will cause BIGSORT to start sorting 
  71.           items from that column. If omitted, BIGSORT sorts the file 
  72.           starting from the first character.
  73.           
  74.   /+nnn-mmm where nnn and mmm are the column numbers, causes the program 
  75.           to focus only on the area between those two columns. This 
  76.           option can be repeated as many times as necessary to specify 
  77.           secondary sort keys. See the chapter on multiple keys.
  78.             
  79.   /R      Reverses the sort order. The sorting order will be descending 
  80.           order for that field, if this option is specified.
  81.  
  82.   /Ds     Specifies the symbol to use as a delimiter for the date 
  83.           symbol. 's' can be either a dash "-", a slash "/", a period 
  84.           "." or nothing. If "/D " is specified, BIGSORT assumes that 
  85.           the digits are attached to each other, like 19921220, to 
  86.           specify a date of Dec 20th, 1992. Default: /D-
  87.           
  88.   /I      Ignore case. Without this option, A comes before a, and Z comes
  89.           before a. Use this option to prevent this.
  90.  
  91.   /MMDDYY The field is a date field, in the format of MM-DD-YY. Unless 
  92.           the /D option is specified, BIGSORT assumes that dashes 
  93.           separate the digits.
  94.   /DDMMYY Similar - the data field is in DD-MM-YY format.
  95.   /YYMMDD Similar - the data field is in YY-MM-DD format.
  96.   
  97.   /Snnnn   Specifies the index size for the file. One index entry per 
  98.           each line in your file is needed to load the file. Normally 
  99.           BIGSORT reserves a room for 100 thousand lines. If the number 
  100.           of lines (or records) in your file is more than 100 thousand, 
  101.           you need to specify the /S option. For example, if your file 
  102.           is 200 thousand lines, and you expect it to grow, you may tell 
  103.           bigsort to reserve room for 500 thousand:  /S500000
  104.  
  105.   /N      Indicates that the field specified is a numeric field, thus a 
  106.           numeric comparison should take place. This prevents leading 
  107.           blanks and other characters from interfering with the sorting 
  108.           order of numbers. If /N is specified, BIGSORT compares the 
  109.           field contents after converting them to floating-point 
  110.           numbers. This ensures accurate sorting of numbers with decimal 
  111.           places.
  112.           
  113.  
  114. Specifying Ranges
  115. -----------------
  116.  
  117. Ranges limit the area where BIGSORT should focus on. For example, if you 
  118. wanted to sort the files displayed with OS/2 DIR command, based on the 
  119. file sizes, you could tell BIGSORT to sort the data based on the 
  120. information contained between column 17 and 27. The option for that 
  121. would look like:  "/+17-27".
  122.  
  123. Options are parsed from left to right, changing the internal defaults as 
  124. it goes along. When BIGSORT comes upon a range field, it records the 
  125. current setting of such options as "/R", "/I", "/N" and date-related 
  126. options, for that range. It then resets these options to the defaults, 
  127. to enable you to construct a completely new set of rules of your second 
  128. sort field specification, if any.
  129.  
  130. Let's see this with an example. Let's try to sort DIR's output on 
  131. creation date, and then on the name. Our idea is to display the files in 
  132. the chronological order, but files created on the same day, should be 
  133. sorted by name within themselves.
  134.  
  135. Here is a ruler line, followed by a sample output of the DIR command:
  136. 12345678901234567890123456789012345678901234567890
  137.  
  138.   9-11-92  8:01p     <DIR>         922  .
  139.   9-11-92  8:01p     <DIR>         690  ..
  140.  12-22-92  7:14p      5638           0  BIGSORT.BAK
  141.  12-22-92  7:42p      5267           0  BIGSORT.C
  142.  12-22-92  7:14p       869           0  BIGSORT.H
  143.  12-22-92  8:44p      5167           0  BIGSORT.TXT
  144.  12-22-92  7:12p      3004           0  COMPARES.C
  145.  (...)
  146.  
  147.  
  148. The command to give to BIGSORT to sort the above list would be:
  149.  
  150. DIR | BIGSORT /MMDDYY /d- /+1-9 /i /+41-80 > myfile.output
  151.  
  152. Let's analyze this command. When OS/2 "sees" this line, it first erases 
  153. and opens the "myfile.output" which will store the results of the 
  154. operation. It then runs the "DIR" command, passing its output to BIGSORT 
  155. with all the parameters.
  156.  
  157. When BIGSORT starts, it defaults to using its case-sensitive 
  158. alphanumeric sort. The first option changes this to the sort on the date 
  159. field. The second option specifies that the month, days and year digits 
  160. are separated by dashes, which is the default, by the way. When we 
  161. specify the range, "/+1-9" our /MMDDYY option is recorded as the desired 
  162. sort method for the first range, and BIGSORT resets the sort method to 
  163. case-sensitive alphanumeric sort. Now it reads the "/I" option and 
  164. switches its current sort method to case-insensitive, alphanumeric sort. 
  165. When it reads the "/+41-80" range specifier, it records that our second 
  166. field selection should be sorted using an alphanumeric, but 
  167. case-insensitive sort.
  168.  
  169. When BIGSORT is done, it sends the result to "standard output" which has 
  170. been redirected to a file with the "> myfile.output" part of the 
  171. command. 
  172.  
  173. Each time a range is specified, the specified options are recorded for 
  174. that range, and the options are reset. Thus, you may have to specify the 
  175. same option several times in the command line, in some cases. For 
  176. example, to sort on the Lastname, then on the firstname, both using 
  177. case-insensitive sort, you need to put something like:
  178.  
  179.         TYPE myfile | BIGSORT /i /+10-25 /i /+27-40
  180.  
  181.  
  182. Multiple Ranges
  183. ---------------
  184.  
  185. BIGSORT accepts up to twenty ranges. This means that you can specify up 
  186. to twenty different "zones" in your data for BIGSORT to sort on. 
  187. Multiple key fields are useful if you wish for example that your 
  188. database output be sorted on the date field, and within that, on the 
  189. last name of the person. You can tell BIGSORT to sort the first field 
  190. definition corresponds to a date, and the second one to a name. This 
  191. way, BIGSORT will continue sorting records on the name, if the dates are 
  192. identical.
  193.  
  194.  
  195. BIGSORT and multiple files:
  196. ---------------------------
  197.  
  198. If you wish to sort and merge several files into one, you can do it with 
  199. one command under OS/2. Just do a:
  200.  
  201. TYPE *.* | BIGSORT > result.txt
  202.  
  203. Note that the TYPE command also sends the filename of the file it is 
  204. processing, to "standard output". You may have to manually remove such 
  205. records.
  206.  
  207. BIGSORT Swap Area:
  208. ------------------
  209.  
  210. BIGSORT creates no swap area of its own, but uses OS/2 to allocate 
  211. necessary memory to load the entire file, along with an index pointer 
  212. for each line. You can "guesstimate" that an input file of 8MB, will 
  213. occupy a little over 8MB of RAM when BIGSORT is working on that file. 
  214. OS/2 will first allocate all available RAM, then provide the rest from 
  215. its swap area. Since this area grows and shrinks automatically, there is 
  216. nothing wrong with having a temporarily large swap file. 
  217.  
  218.  
  219. Shareware
  220. ---------
  221.  
  222. BIGSORT represents countless hours of work. Please contribute to the 
  223. shareware discipline by sending $20 of registration fee to:
  224.  
  225.         Turgut Kalfaoglu
  226.         1378 Sok. 8/10
  227.         Izmir 35210
  228.         Turkey
  229.         
  230.  
  231.  
  232. Source Code
  233. -----------
  234.  
  235. BIGSORT is compiled under IBM C/SET 2, at CSD level 28. Clear and 
  236. well-documented source code with documentation is available ONLY to the 
  237. registered users. Send $10 (to cover shipping charges) and a blank disk 
  238. (3.5 format) to the above address to receive the source code.
  239.  
  240. The author encourages you to register, but also to ask for additional 
  241. features, or comments. Please don't think that you need to register this 
  242. software for additional features or to report problems or suggestions. 
  243. However, regular use requires a donation of $20 to the above address.
  244.  
  245.  
  246.  
  247. Update History
  248. --------------
  249.  
  250. Version 4.1:
  251. ------------
  252.  
  253. Implements the "/N" option. No bugs were found with 4.0.
  254.  
  255. Version 4:
  256. ----------
  257.  
  258. Implements multiple key fields,
  259. Implements sort ranges,
  260. Implements the /D option.
  261. Implements country-specific information
  262.  
  263. Version 4 is almost a complete re-write with division of source code 
  264. into five segments.
  265.  
  266.  
  267. New Version: V3
  268. ---------------
  269. Implements unlimited input filesize.
  270.  
  271.  
  272.  
  273. New Version: (V2.1 to V2.2)
  274. ---------------------------
  275.  
  276. Added features: It can now handle dates as well!
  277.                 Now /R and /I can be used at the same time.
  278.                 Improved performance, but code size still about
  279.                 the same (you should see the tricks that were done
  280.                 to keep it that way :)
  281.  
  282. Bugs Removed:   None were found in V2.1
  283.  
  284.