SORT

From ICE Enterprises
Jump to navigation Jump to search

Sorts a Type 3000 file.

<IN>      The input file.
<OUT>     The output file.
<KEYS>    The keys to sort by (separated by '|').

DESCRIPTION:
  This will sort a Midas BLUE Type 3000 file. The input file will be read in
  and then the data will be sorted before writing out to the output file. The
  provided keys specify which key or keys to sort by. They should be in the
  form:
    <KEYS> = "key1|key2|key3"

  This will sort with "key1" as the primary key, and "key2" as the secondary
  key (used where multiple "key1" values match), and so forth.

  This primitive is intended for use with only small data files. The following
  assumptions were made when the primitive was written:
    1. The entire file can be read into memory prior to sorting.
    2. The sort algorithm need not be highly optimized. (Though
       it is optimized in the current implementation.)
    3. The keys specified will match the fields in the records.
    4. All values for a given field will be of the same data type.


SORT ORDER:
  To "normal"-sort on a key (smallest-to-largest) prefix the key name with a
  plus sign ('+'), or give it no prefix. Such as:
    <KEYS> = "+key1|+key2|+key3"   or   <KEYS> = "key1|key2|key3"

  To reverse-sort on a key (largest-to-smallest) prefix the key name with a
  minus sign ('-'). Such as:
    <KEYS> = "-key1|-key2|-key3"

  Mixing the sort order between keys is permitted. Such as:
    <KEYS> = "key1|-key2|+key3"


EXAMPLES:
  1. Sort the 'testxy3000' file based on 'ABSC':
       nM> sort testxy3000 outfile absc

  2. Sort the 'testxy3000' file based on 'ABSC',in the reverse order
     sort key (for instances where 'ABSC' values match):
       nM> sort testxy3000 outfile -absc

  3. Sort a file based on multiple keys:
       nM> sort inFile outFile "-SINT|-NAME|+SLNG"