sort Command

Sorts lines of text.

Scope: Document

Syntax

Parameters

Number 
Sort from the current line up to, but not including, line Number in the file
+Number 
Sort the next Number lines, starting with the current line
BLOCK 
Sort all lines in a block of selected text
* 
Sort all lines from the current line to the end of the file, including the last line in the file
Mmark 
Sort from the current line up to, but not including, the line containing the named mark mark.
"string" 
Sort from the current line up to, but not including, the line containing the next occurence of the string expression specified in string.
A 
Sort by ascending string value. This is the default if a sort ordering type is not specified.
D 
Sort by descending string value
AN 
Sort by ascending numeric value
DN 
Sort by descending numeric value
AI 
Sort by ascending string value, ignoring character case
DI 
Sort by descending string value, ignoring character case
col1 col2 
A pair of column numbers defining a sort field within each line. Column numbers are always absolute column numbers. Up to 100 pairs of column numbers can be defined as part of a sort command line invocation, with highest sort priority given to the first column number pairs appearing in the command line invocation. If no column number pairs are specified, the entire line is considered to be the sort field.

Description

The sort command provides a method of sorting information in specific areas of a file. Options associated with the sort command let you define sort fields for data in specific locations on each line, and apply the sort operation to specific sets of lines.

The BLOCK option of the sort command lets you restrict sort operations to only blocks of selected text, including rectangular blocks of text if the blockdefaulttype parameter is set to rectangle.

Examples

  1. To sort from the current line up to but not including line 25 of the file, type:
    sort 25 
  2. To sort 25 lines in descending string order, starting from the current line, type:
    sort +25 D 
  3. To sort a block of selected text in ascending case-insensitive string order, based on the contents of columns 10 to 15 of each line in that block, type:
    sort BLOCK AI 10 15 
  4. To sort from the current line up to and including the last line in the file, in ascending numeric order, based on sequence numbers in columns 73 to 80, type:
    sort * AN 73 80 
  5. To sort from the current line up to but not including the line with a named mark called Limit, in ascending order, based first on the contents of columns 10 to 15, and then the contents of columns 5 to 6, type:
    sort Mlimit A 10 15 5 6 
  6. To sort from the current line up to but not including the line containing the next instance of the string arbitrary, in ascending order, type:
    sort "arbitrary" A 

API Return Codes

-1 
String or mark not found
-2 
Invalid parameter argument supplied
-6 
Bad block defined
-8 
Out of memory

blockdefaulttype Parameter