Sunday, July 11, 2010

How To Use Advanced Sort/Options?

This command allows you to set the sort options and perform a sort of the active file.  The sort is performed on the complete file unless a portion is selected.  If a portion is selected, just the selected portion will be sorted.  However ALL the lines selected will be sorted, not just selected columns if in column mode.  The UNDO command is not supported with sort operations.

When this option is selected, a dialog is presented with the following options:

Sort Order
Ascending                This sets the sort for ascending order ('a' to ' z', 1-9) and is the default.
Descending             This sets the sort for descending order (' z' to 'a', 9-1).

Remove Duplicates
If this is checked, then the associated radio button options Where All Selected Keys Match and Where Any Selected Keys Match become active and may be selected.  

If Where All Selected Keys Match is selected, duplicate strings/characters must exist in ALL active sort keys for a line to be considered a duplicate and be removed.  If Where Any Selected Keys Match is selected, a line is considered a duplicate if duplicate strings/characters exist in ANY of the active sort keys.  Active keys are designated using the checkboxes under the RD heading.  This allows the user greater flexibility in determining which defined keys are used for the Remove Duplicates sort operation.

Ignore Case
If the Ignore Case option is set, lines are considered identical if the characters are the same with the only difference being the case of them.  This option should be checked if you want the search to be insensitive to case, i.e. "CAT" is considered the same as "cat".  Do not check this option if the sort should consider "cAT" different from "cat".

Numeric Sort
If this is checked, the sort will perform a numeric sort on the selected columns.  Typically a sort is non-numeric and the values 1,11,111 would be sorted before 2,22,222 as 1 comes before 2.  If a numeric sort is selected, the values would be sorted in numeric order (1,2,11,12,111,222).  The numeric sort is not possible with a locale specific sort or when using the alternate sort method.  The numeric sort option should not be selected when sorting only alphabetical characters.

Sort Columns
Up to 4 sort keys may be selected to sort on.  Each sort key contains a range of columns that will be sorted.  The normal value for the range is from column 1 to 9216.

The start and end columns for unused keys should be set to 0.  If multiple keys are used, the sort order is based on the first key, followed by the second key, etc.

To sort by complete line set the start column to 1 and the end column to –1.  If any key has a value of –1 for the end column the sort will be from the start column to the end of line.  If any key is set to sort the complete line the rest of the sort keys will be ignored.

If the start column is 0 for any sort key (and not sorting by line) the start column will be the column of the cursor.

Sorting performance is better when less keys are used and when less columns are sorted on.

The sort uses memory mapped files and virtual memory.  In some cases it may be necessary to use an alternate sort that allows the user to specify where the temporary files will be used.  If this is the case the Alternate Sort not using Virtual Memory should be checked and only a single sort key may be used (and non-numeric).  This is exactly the same as earlier versions that only supported single keys.

Use Locale (Slower)
This specifies that the sort should be locale specific.  For some languages (e.g. German) this is required to change the default sort order.  The locale to be used can be specified under the Advanced Menu and Set Code Page/Locale.  When using this setting the sort may be slower than when not doing so.  A locale specific sort is not possible if Alternate Sort not using Virtual Memory is selected.

These options are saved between UltraEdit sessions and are used by the Sort File command