Sort tools

From TED Notepad
(Redirected from Sorting tools)
This section is up to date for TED Notepad version 6.3.1.0.
Control page Control:menu:Sort tools

Ascending (Alt+Ctrl+A)

[Section link: Sort Lines Ascending]

Sorts lines of the selection in ascending order, comparing the entire lines as simple text. Does not ignore case or any characters upon comparison.

See also Sort Lines Descending and Sort Lines tools.

See also Shuffle Lines tool.

Descending (Alt+Ctrl+Z)

[Section link: Sort Lines Descending]

Sorts lines of the selection in descending order, comparing the entire lines as simple text. Does not ignore case or any characters upon comparison.

See also Sort Lines Ascending and Sort Lines tools.

See also Shuffle Lines tool.

Sort.. (Alt+Ctrl+S)

[Section link: Sort Lines]

Sorts lines of the selection according to the given sorting keys.

Up to five sorting keys can be used, each sorting key represented by its own tab in the Sort Lines dialog: First, Second, Third, Then, and Finally. Sorting keys are used subsequently ony by one, i.e. if two lines are considered equal acording to the First key, then the Second key is used, etc. In other words, to have the Finally key harnessed/employed, all four preceeding sorting keys must yield indecisive comparison.

Note: Each sorting key offer a special Nothing option, which turns off the entire key. Such key is not used for comparing lines upon sorting, but it does not prevent later sorting keys from being queried. Using Nothing option has the same effect as setting up a sorting key, which would always yield indecisive comparison.

Note: Sorting keys are used only to compare and sort the lines, e.g. to decide, which one goes first and which one will be the second one. The lines themselves are not being modified, only their order.

Cutting line portion

Each sorting key may cut portions from lines, which are to be used for comparison upon sorting.

Cutting portion of a line is divided into two successive parts. First, columns are cut from the line, by either:

Note: Columns are cut for each line separately, therefore the total number of columns on a line may vary from line to line. If specified column number is beyond the total number of columns, empty zero-length portion is cut for such column from that line. Therefore, it is allowed to cut columns 2-7, even though some lines do not have enough columns to offer.

After the first part (cutting columns from the line), the resulting portion of the line can be further cropped by turning Use only characters option on, and specifying a range of character positions between from position and to position. This cuts off everyting before the from position and everyting after the to position.

  • Calculate the position backwards: from right to left can be used to numerate the character positions from the end of line rather than the usual way. Note, however, that this only affects how the positions are numbered before they are cropped; the text itself is not reversed.

Note: Range of character positions is always cropped after columns are cut. If a range is specified beyond currently cut columns, empty zero-length portion is cropped from that line, even if the original line continues after the cut columns. In other words, range of character positions cannot bring back what has already been cut off by previous step.

Note: There is currently no way to cut columns after cropping a range of character positions.

Note: Column preview button displays a small portion of lines transformed by current dialog values. Be aware that preview is always generated from the current selection. If there is no selection, then there is nothing to preview.

Direction and format

The meaning of each sorting key is specified by Sort as options.

  • Text option tells that each portion of line previously cut is to be treated as a simple string of characters upon comparison — comparison of two strings of characters is done lexicographically, i.e. by subsequently comparing each pair of corresponding characters from both strings (the first pair of different characters is the one that decides which string is greater).
  • Numbers option tells that each portion of line previously cut is to be treated as a number upon comparison — comparison of two numbers is done by their natural order.
    • A number may, in general, consist of a sign, numerals, decimal point and more numerals. Any of those may be omitted, e.g. 3.14, +2.0, 2., -7, .3 are all valid numbers. Total count of digits in a number is not limited. Note: Individual separate decimal point (.) or solitary positive/negative sign character (+ or -) with no numerals following, as well as empty number (empty string), are all treated as zero.
    • Note: System locale settings (Regional settings) are used while comparing numbers. This includes localization of decimal point, positive and negative signs, thousands separator, etc.
    • Note: All alpha-numeric characters are considered valid numerals, thus hexadecimal numbers (or any other system with radix up to 36) are supported. All numbers must share the same radix, however.
    • Note: All white-spaces are automatically ignored upon comparing numbers, and character case is ignored as well.
    • Note: The first unrecognized and non-ignored character after a recognizable number terminates that number. Any following text is ignored. Also remember that all alpha-numeric characters are considered valid numerals and all white-spaces are ignored, thus perhaps a bit mystifying, 3 pigs is a valid number, which is bigger than 3 cows, but is far far less than 1 elephant. This is because both 3pigs and 3cows have 5 digits while 1elephant has 9 digits. It is similar as if comparing 37198, 32048 and 131375429. Tricky, isn't it?
    • See chapter Appendix for further details and examples of recognized number formats.

Each sorting key can specify the resulting order of sorted lines using the Direction with two intuitive options: Ascending or Descending.

Options

Additional options are available to further modify, which characters are compared and which are ignored upon comparison.

If a character is to be ignored upon comparison, it is as if all occurrences of such character were deleted before the comparison. Note, however, that the characters are never physically removed from the lines — the resulting lines are not modified by this tool.

Note: Set of characters to be actually ignored upon comparison is a union of all ignored characters as specified by the options above. Note that even if Ignore all but option specifies some character, Ignore characters option can take it off the table.

See also Sort Lines Ascending, Sort Lines Descending and Sort Lines tools.

See also Shuffle Lines tool.

Shuffle (Ctrl+Shift+K)

[Section link: Shuffle Lines]

Reorders lines of the selection randomly.

Warning: Although the tool uses a more complex pseudo-random generator (than a linear congruential generator), it is not safe to assume that the generator is cryptographically secure. This tool should not be used for encryption purposes if real sturdy protection is expected, since the pseudo-random generator is not constructed to withstand real cryptanalysis. It is only safe to assume that the generator is not easily predictable without advanced cryptanalysis — which is acceptable for most common tasks.

See also Sort Lines Ascending, Sort Lines Descending and Sort Lines tools.