Sort Lines

From TED Notepad
Revision as of 16:13, 2 May 2011 by Jsimlo (talk | contribs) (Created page with '<noinclude>{{manversion|5.3.0.2}}__NOTOC__</noinclude> ====Sort... (Alt+Ctrl+S)==== Shows {{dialog|Sort Selection}} dialog and asks for {{field|sorting keys}}. Then sorts {{defi…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
You see work in progress here; this section already reflects future TED Notepad version 5.3.0.2.
This section may contain incomplete, premature, or mistaken information, prone to change without notice.

Sort... (Alt+Ctrl+S)

Shows Sort Selection dialog and asks for sorting keys. Then sorts lines of the selection according to the given keys.

When lines of the selection are being sorted, they are compared against each other and the sorting keys are supposed to specify, how to do that. You can use up to three such keys, named At first..., Then... and Finally.... If two lines are equal acording to the 1st key, then the 2nd key is used (and the 3rd key alike).

Note: The sorting keys are used only to sort the lines, e.g. to decide, which one goes first and which one will be the second one. The lines are not being modified during the sorting; only the order of them.

Each sorting key may specify:

Whether to sort by that key, or not.
There is usually no need to define more than one key, therefore the 2nd and 3rd keys are disabled by default.
Note: You can not sort by the 3rd key, if you are not sorting by the 2nd key as well.
Whether to use an entire line or only a specific column for the comparisons.
When lines are being compared, only this column is taken into account, disregarding any other line content.
Note: The column is being allocated for each line separately, therefore the total number of columns on a line may vary from line to line. If you run out of columns on a line, you get an empty column for that line.
None, one or more column delimiters may be specified.
Each delimiting character is treated independently and are all case sensitive. You can, for example, dilimit columns by Spaces and also by Tabs. Then each Space or Tab (whatever comes first) starts a new column.
Example: A line HELLO WORLD would be:
  • divided into two columns (HELLO and WORLD), if delimited by a Space character;
  • divided into four columns (H, LL,  W and RLD), if delimited by a set of EO characters;
  • divided into four columns (HE, {empty}, O WOR and D), if delimited by a single L character;
  • and divided into only one column (HELLO WORLD), if delimited by an X character or if delimited by no characters.
Whether to treat a sequence of delimiters as a single delimiter.
Tells that any sequence of a single delimiter is to be treated as a single delimiter. For example, in a string with several consecutive Spaces, all sequences of Spaces will be grouped together first. Only then the line will be divided into columns.
Note: A sequence of multiple delimiters is not treated as a single delimiter. If a Space is followed by a Tab, both Space and Tab are delimiters, they will delimit three columns instead of two, leaving the second column empty.
Example: If this option is checked, a line HELLO WORLD would be divided into only three columns (HE, O WOR and D), if delimited by a single L character, exactly as if there was only one single L in the word HELLO.
Whether to count columns backwards.
If this option is checked, then a column 1 from left is the last column, column 2 from the left is the penultimate column, etc. Note again, that columns are set for each line separately, therefore total number of columns on a line may vary from line to line. If you run out of columns on a line, you get an empty column for that line.
Whether to use only a char range.
If this option is checked, then only this char range of a chosen column is used when sorting lines. Note, that the columns are calculated first. Only then the char range is cut from the resulting column. If you run out of chars in the column, you get an empty string for that line, even if the line originally continued after the column.
Whether to count the char range backwards.
Very similar to count columns backwards above.
Note, that even if a char range is counted backwards, the comparing of two lines is performed normally, from left to right. If you wish to compare lines backward, try to use the Reverse Lines tool to reverse the lines before and after the sort. For details see chapter Replacing tools.
Sorting Direction: ascending or descending.
The tool always uses the actual locale settings to decide the order of the lines.
Whether to compare two lines as numbers or as text.
Note, that number 112 is greater than number 12 if sorted as numbers, but it is smaller if sorted as text.
Sorting numbers
While sorting as numbers, all spaces are automatically ignored. TED Notepad is able to sort numbers of any length. The numebers may contain one decimal point and may start with a minus sign.
The comparison of two numbers is halted, when a first non-allowed character is found. The allowed characters are 0-9, a-z, one decimal point, a minus sign at the beginning and all white-spaces.
The numbers may be in decimal, binary, hexadecimal or any other scale. The only important thing is, that both compared numbers must be in the same scale. This also means, that you cannot compare a line like 13 pigs against a line like 13 elephants, because the letters are valid numerals. In this case, 13 pigs are greater that 13 elephants.
Actually, 1 woman is always more than 1 man no matter what... On the other hand, 1$ woman and 1$ man are equal when compared as numbers.
Whether to ignore case when comparing two lines.
The case is always ignored when sorting as numbers.
Whether to ignore specific characters, when comparing two lines.
If a character is to be ignored, it is completely stripped from both lines when they are being compared.
Note: While comparing as lines, you can not specify, which characters are to be ignored.
Note: The resulting lines are not modified, and the ignored characters are not stripped from the results.