Please enable JavaScript to view this site.

A-Shell Reference

SORT filespec

SORT performs line-by-line reordering of text files. It prompts for the necessary options, so it is largely self-explanatory, as shown in the following example.

.SORT somefile.txt

Record size: 80

Key length: 10

Key position: 1

Key order (A/D{N}{F} or ? for help) : ?

   Enter: A(scending) or D(escending) followed optionally by N and/or F

   N=natural (more 'human' - group digits, ignore spaces, etc.)

   F=fold (treat upper/lower case as equivalent)

Key order (A/D{N}{F} or ? for help) : AN

 

Key length:

 

It prompts for up to three sets of key parameters (length, position, order). The file is then sorted in place, replacing the original. The "record size should be set to the length of the longest line in the file.

Unlike Xcall BASORT, there is no option for binary or floating point key types, as this is intended purely for sorting text files. The "natural" sort order option (see History, below) uses an algorithm by Martin Pool that relaxes the strict ASCII byte-by-byte sorting rules to yield something more likely to seem natural to humans. For example, "100 Main St." would sort after "99 Main St."

History

2017 January, A-Shell 6.3.1542, SORT.LIT 1.1(106):  now supports localization; see LITMSG.xxx 056,### for message customization. Also, the display has been updated to show the number of records sorted.

2009 January, A-Shell 5.1.1136, SORT.LIT 1.1(104):  now supports the "natural" sort option and also the fold (case insensitive) option. The options may be specified individually for each key by appending "N" (natural) and/or "F" (fold) to the A or D currently used to specify Ascending or Descending.