SORT [(line1 line2)] [[A|D] where, [A|D] where, ...] SORT
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.
Examples:
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. |
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:
initialcolumn length
initialcolumn : finalcolumn
Finally, you may put commas between the field specifications in order to make them easier to read.
Some examples:
sort d
sort 16:18, 24:26
sort 1 5, d 6 5
sort(300b)16 8
sort d(1 3 4:10
sort n(1 5/6:10) d 11:15 / 16 5
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:
Sorted
Contrasting, if an error occurred, you get one of the following messages:
First number larger than second
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.
Number ... not found
You specified the number of a line that does not exist.
There is no previous record
You used the symbolic line number p although there are no records previous to the record in the current line.
There is no next record
You used the symbolic line number n although there are no records behind the record in the current line.
You cannot sort the top line
You included the top line in the records to sort but it cannot be sorted.
Begin column larger than end column
You specified a sorting field with the quality mentioned.
Sort fields overlap
There is at least one column that occurs in two field specifications.