vEdit has both a sort function EDIT > Sort > Sort lines for sorting lines (single line records), and the SORTMAIL macro for sorting records consisting of multiple lines. Both support variable-length and fixed-length records.

Basic Sorting

The EDIT > Sort > Sort lines function sorts all lines in the entire file or just in the highlighted block. It first displays a dialog box with sort options and an input box for entering the columns for the primary “sort key”, and optionally, for up to nine secondary key fields (column ranges).

If no block is highlighted, the default is to sort the entire file with a sort key beginning in column one. If a columnar block is highlighted, the default is to sort only the lines within the block, using the highlighted columns as the sort key.

Options include ascending/descending, case-sensitive, and disabling the current “ collate table ”. A collate table is normally used to set the sort order of special characters. For example, the default table equates spaces and Tab characters, and sorts European characters, such as “u umlaut” immediately after “u”. Collate tables are described in detail below.

vEdit’s sorting speed is among the fastest in the industry. A 100-megabyte file can be sorted in about three minutes on a typical 1-GHz computer. When sorting a huge file we highly recommend that the file reside on the local hard disk and not on a network server.


Sort Lines Collate Table.png


Sort All Lines in the Entire File

  1. If you have made changes to the file, you should select FILE > Save to make sure your changes are saved. You cannot “undo” sorting, except by reloading the original file.
  2. Select EDIT > Sort > Sort lines.
  3. The sort dialog box is displayed. The primary sort key will simply default to columns 1 - 160. Change any desired options. The default is an ascending sort which equates upper and lower case, and uses the current collate table.
  4. Select OK to begin the sort. If it is a huge file, vEdit will display its progress.

You can easily sort an entire file or all lines in a block according to a “key” field such as the “Last-name” or “Zipcode” in a database.


Sort All Lines in a Block by a Key Field

  1. Position the cursor on the first line to be sorted and in the left-most column of the field to be used as the “sort key”.
  2. Select BLOCK > Set column marker ( Alt-I or toolbar) to begin a columnar block.
  3. Position the cursor on the last line to be sorted and in the right most column of the field to be used as the “sort key”. To sort an entire file, this must be the last line of the file.
    • Select BLOCK > Set column marker (Alt-I or toolbar) again.
  4. Select Edit > Sort > Sort Lines.
  5. The sort dialog box is displayed. The primary sort key will be preset to the highlighted columns.
    • Change any desired options. The default is an ascending sort which equates upper and lower case, and uses the current collate table.
  6. Select OK to begin the sort. If it is a huge file, vEdit will display its progress.

Sorting by Multiple Fields

Sorting must sometimes be based on multiple fields. For example, you might want to sort by “Zipcode” and within the same “Zipcode”, sort by “Last-name”, and within the same “Last-name”, sort by “First-name”. vEdit easily performs such sorts in one operation.

Sort a File Based on Multiple Fields

  1. Determine the beginning and ending column numbers for the desired primary and secondary key fields.
  2. Select Edit > Sort > Sort Lines.
  3. The sort dialog box is displayed. Enter the column numbers for the key fields, primary field first.
    • The dialog box gives an example of how to enter the column numbers.
  4. Change any desired options, Click Ok to begin the sort.

If it is a large file, vEdit will display its progress.

Related Resources