next previous up contents index
Next: SSPLIT Previous: SKEY Up: The Commands in Detail

SORT   [(line1 line2)] [[A|D] where, [A|D] where, ...]

With the command SORT you can sort records. You cannot abbreviate this command, thus you cannot type it by mistake; normally, this would be irreparable.

If the specification (line1 line2) is missing, the entire workfile is sorted. With the specification of (line1 line2) you can restrict the sorting to a part of the records. The numbers may be record numbers with or without leading zeros, or the specification may be of a symbolic line number as described at the entry of the command COPY. The first number must not be larger than the second.

sort (500 b) ... sorts the lines 500 to the end of the workfile,
sort (f n) ... sorts the lines from the first line to the line after the current line.
Additionally, you may specify the orientation, type, and fields of the sorting. If you omit all further parameters, the records will be sorted in ascending, case-sensitive and alphabetical order (including numbers). Also the complete records will be used for comparison.

The orientation of the sort is specified by A (= ascending) for ascending sort and D (= descending) for descending sort. The orientation may be specified for every field separately. If you leave out the specification, exaEdit assumes A (ascending).

To turn off the case sensitivity you have to use the parameter I (case insensitive). This too has to be given for each sorting field where this is wanted.

If the fields that are to be sorted contain numbers, you have to use the parameter N (numerical) for each sorting field where this is required. When sorting numerically, the record or the given sorting field is interpreted as a number. The function atoi of the programming language C is used for this. This means the interpretation ends when the first character that is not a number is reached (this may be before the end of the record or the sorting field is reached). Additionally, this means the number being interpreted as 0 if no number has been found, an undefined interpretation if the number found was too large, the acceptance of white spaces (i.e. spaces, tabs, line feeds, page feeds, end of record characters) and the possibility of writing numbers using decimal points or not and using exponential format or not.

For the specification of the sorting fields (i.e. the where in the SORT syntax above) there are two possibilities:

or The two methods may be mixed. The parameters explained above (A, D, I and N) can be specified ahead of each sorting field. If you want the same parameters in effect for multiple sorting fields in parentheses and specify the parameters just once ahead of those parentheses.

Finally, you may put commas between the field specifications in order to make them easier to read.

Some examples:

The last example shows the use of 4 sorting fields, all of which are 5 characters in length. The first two fields are sorted numerically, the last two alphabetically. Only the third field is sorted descendingly, all others are sorted ascendingly.

If exaEdit has sorted successfully, you receive the message:

Contrasting, if an error occurred, you get one of the following messages:

In this case, in the parentheses with the line number specification, the value of the first numerical or symbolic line number is larger than the second.

You specified the number of a line that does not exist.

You used the symbolic line number p although there are no records previous to the record in the current line.

You used the symbolic line number n although there are no records behind the record in the current line.

You included the top line in the records to sort but it cannot be sorted.

You specified a sorting field with the quality mentioned.

There is at least one column that occurs in two field specifications.

next previous up contents index
Next: SSPLIT Previous: SKEY Up: The Commands in Detail