@@ -17,10 +17,12 @@ Example:
1717sort field "Output"
1818
1919Example:
20+ local tNumbers
2021put "5,4,3,2,1" into tNumbers
2122sort items of tNumbers ascending numeric -- 5,4,3,2,1 becomes 1,2,3,4,5
2223
2324Example:
25+ local tData
2426put "1,ben" into line 1 of tData
2527put "2,elanor" into line 2 of tData
2628put "3,ali" into line 3 of tData
@@ -32,6 +34,7 @@ sort lines of tData descending numeric by item 1 of each
3234# 1,ben
3335
3436Example:
37+ local myInfo
3538sort items of myInfo by word 2 of each -- sort by word 2 of the line
3639
3740Parameters:
@@ -49,50 +52,51 @@ sortType (enum):
4952If you don't specify a <sortType>, the <sortType> is `text`.
5053
5154- international: sorts by collation according to the system locale
52- - numeric: sorts by number. (Use this form if the sortKey consists of
53- numbers)
54- - datetime: treats the sortKey as a date and/or time
55+ - numeric: sorts by number. (Use this form if the sortKey consists of numbers)
56+ - datetime: treats the <sortKey> as a date and/or time
5557- text: sorts using a codepoint by codepoint comparison
5658- binary: sorts using a byte by byte comparison
5759
5860
5961sortKey:
60- An expression that evaluates to a value for each line or item in the
61- container. If the sortKey contains a chunk expression, the keyword each
62- indicates that the chunk expression is evaluated for each line or item.
63- If you don't specify a sortKey, the entire line (or item) is used as the
64- sortKey.
62+ An expression that evaluates to a value for each line or < item> in the
63+ container. If the < sortKey> contains a chunk expression, the keyword
64+ <each> indicates that the < chunk expression> is evaluated for each line
65+ or <item>. If you don't specify a < sortKey> , the entire line (or < item>)
66+ is used as the < sortKey>.
6567
6668Description:
67- Use the sort container command to shuffle the order of lines or items in
68- a container.
69+ Use the < sort container> command to shuffle the order of lines or
70+ <item|items> in a container.
6971
70- If you don't specify lines or items, the lines of the container are
71- sorted.
72+ If you don't specify lines or <item| items> , the lines of the container
73+ are sorted.
7274
73- The each keyword, when used in the sortKey, specifies the entire line or
74- item. You can use the each keyword in an expression, as a placeholder
75- for the current line or item. For example, this statement sorts the
76- lines of a variable by the third word of each line:
75+ The < each> keyword, when used in the < sortKey> , specifies the entire line
76+ or < item> . You can use the < each> keyword in an expression, as a
77+ placeholder for the current line or < item> . For example, this statement
78+ sorts the lines of a variable by the third word of each line:
7779
78- sort lines of myVariable by word 3 of each
80+ sort lines of myVariable by word 3 of each
7981
80- You can use the each keyword in any expression, not just chunk
81- expressions.
82+ You can use the < each> keyword in any expression, not just < chunk
83+ expression|chunk expressions> .
8284
83- The sort container command is a stable sort. This means that if the
84- sortKey for two items or lines is the same, sorting does not change
85- their order, so you can do two successive sorts to create subcategories
86- within the major sort categories.
85+ The < sort container> command is a stable sort. This means that if the
86+ < sortKey> for two <item| items> or lines is the same, sorting does not
87+ change their order, so you can do two successive sorts to create
88+ subcategories within the major sort categories.
8789
88- >*Tip:* To create a custom sort order, use the each keyword to pass each
89- > line or item to a custom function. The value returned by the function
90- > is used as the sort key for that line or item. It is not currently
91- > possible to debug custom sort functions, and doing so could make the
92- > IDE unstable. It is recommended to use logging messages instead.
90+ >*Tip:* To create a custom sort order, use the <each> keyword to pass
91+ > each line or <item> to a custom function. The value returned by the
92+ > function is used as the <sortKey> for that line or <item>. It is not
93+ > currently possible to debug custom sort functions, and doing so could
94+ > make the IDE unstable. It is recommended to use logging messages
95+ > instead.
9396
94- References: sort (command), convert (command), offset (function),
95- text (keyword), each (keyword), ascending (keyword), descending (keyword)
97+ References: ascending (keyword), byte (glossary),
98+ chunk expression (glossary), codepoint (keyword), convert (command),
99+ descending (keyword), each (keyword), item (glossary), offset (function),
100+ sort (command), text (keyword)
96101
97102Tags: text processing
98-
0 commit comments