You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: libscript/src/sort.mlc
+68-60Lines changed: 68 additions & 60 deletions
Original file line number
Diff line number
Diff line change
@@ -3,38 +3,63 @@ module com.livecode.sort
3
3
public foreign handler MCSortExecSortListAscendingText(inout Target as list) as undefined binds to "<builtin>"
4
4
public foreign handler MCSortExecSortListAscendingBinary(inout Target as list) as undefined binds to "<builtin>"
5
5
public foreign handler MCSortExecSortListAscendingNumeric(inout Target as list) as undefined binds to "<builtin>"
6
-
// public foreign handler MCSortExecSortStringListAscendingNumeric(inout Target as list) as undefined binds to "<builtin>"
7
6
public foreign handler MCSortExecSortListAscendingDateTime(inout Target as list) as undefined binds to "<builtin>"
8
7
public foreign handler MCSortExecSortListDescendingText(inout Target as list) as undefined binds to "<builtin>"
9
8
public foreign handler MCSortExecSortListDescendingBinary(inout Target as list) as undefined binds to "<builtin>"
10
9
public foreign handler MCSortExecSortListDescendingNumeric(inout Target as list) as undefined binds to "<builtin>"
11
-
// public foreign handler MCSortExecSortStringListDescendingNumeric(inout Target as list) as undefined binds to "<builtin>"
12
10
public foreign handler MCSortExecSortListDescendingDateTime(inout Target as list) as undefined binds to "<builtin>"
13
11
14
12
--
15
13
16
14
/*
17
15
18
-
Summary: Sorts <Target> in ascending order by comparing its elements on a codepoint by codepoint basis.
16
+
Summary: Sorts <Target> in ascending text order.
19
17
Target: An expression that evaluates to a list of strings.
20
18
19
+
Example:
20
+
variable tTestList as list
21
+
put the empty list into tTestList
22
+
23
+
push "xyz" onto tTestList
24
+
push 2 onto tTestList
25
+
push "abcd" onto tTestList
26
+
push 1 onto tTestList
27
+
28
+
sort tTestList in ascending order -- tTestList is ["abcd", "xyz", 2, 1]
29
+
30
+
Description:
31
+
Text sort is performed by comparing string elements on a codepoint by codepoint basis. Non-string elements come after all string elements in the sort order. The sort is stable, so that non-string elements are not re-ordered relative to each other.
Summary: Sorts <Target> in descending order by comparing its elements on a codepoint by codepoint basis.
42
+
Summary: Sorts <Target> in descending text order.
32
43
Target: An expression that evaluates to a list of strings.
33
44
45
+
Example:
46
+
variable tTestList as list
47
+
put the empty list into tTestList
48
+
49
+
push "abcd" onto tTestList
50
+
push 1 onto tTestList
51
+
push "xyz" onto tTestList
52
+
push 2 onto tTestList
53
+
54
+
sort tTestList in descending order -- tTestList is ["xyz", "abcd", 1, 2]
55
+
56
+
Description:
57
+
Text sort is performed by comparing string elements on a codepoint by codepoint basis. Non-string elements come after all string elements in the sort order. The sort is stable, so that non-string elements are not re-ordered relative to each other.
Summary: Sorts <Target> in ascending order by comparing its elements on a byte by byte basis.
71
+
Summary: Sorts <Target> in ascending binary order.
47
72
Target: An expression that evaluates to a list of binary data.
48
73
74
+
Description:
75
+
Binary sort is performed by comparing data elements on a byte by byte basis. Non-data elements come after all data elements in the sort order. The sort is stable, so that non-data elements are not re-ordered relative to each other.
49
76
*/
50
77
51
78
syntax SortListAscendingBinary is statement
@@ -56,9 +83,11 @@ end syntax
56
83
57
84
/*
58
85
59
-
Summary: Sorts <Target> in descending order by comparing its elements on a byte by byte basis.
86
+
Summary: Sorts <Target> in descending binary order.
60
87
Target: An expression that evaluates to a list of binary data.
61
88
89
+
Description:
90
+
Binary sort is performed by comparing data elements on a byte by byte basis. Non-data elements come after all data elements in the sort order. The sort is stable, so that non-data elements are not re-ordered relative to each other.
62
91
*/
63
92
64
93
syntax SortListDescendingBinary is statement
@@ -71,63 +100,65 @@ end syntax
71
100
72
101
/*
73
102
74
-
Summary: Sorts <Target> in ascending order according to the cardinality of its elements.
75
-
If <Target> is a list of strings, the elements are ordered according to the number
76
-
represented by the largest initial segment of the string that constitutes a decimal number.
77
-
If there is no such initial segment, the element is defined to have the minimum value with
78
-
respect to the ordering.
79
-
Target: An expression that evaluates to a list of numbers, or strings.
103
+
Summary: Sorts <Target> in ascending numeric order.
104
+
Target: An expression that evaluates to a list of numbers.
105
+
106
+
Example:
107
+
variable tTestList as list
108
+
put the empty list into tTestList
109
+
110
+
push "abcd" onto tTestList
111
+
push 1 onto tTestList
112
+
push "xyz" onto tTestList
113
+
push 2 onto tTestList
80
114
115
+
sort tTestList in ascending numeric order -- tTestList is [1, 2, "abcd", "xyz"]
116
+
117
+
Description:
118
+
Numeric sort is performed by comparing numeric elements by cardinality. Non-numeric elements come after all numeric elements in the sort order. The sort is stable, so that non-numeric elements are not re-ordered relative to each other.
Summary: Sorts <Target> in descending order according to the standard total ordering on real numbers.
93
-
If <Target> is a list of strings, the elements are ordered according to the number
94
-
represented by the largest initial segment of the string that constitutes a decimal number.
95
-
If there is no such initial segment, the element is defined to have the minimum value with
96
-
respect to the ordering.
97
-
Target: An expression that evaluates to a list of numbers, or strings.
129
+
Summary: Sorts <Target> in descending numeric order.
130
+
Target: An expression that evaluates to a list of numbers.
131
+
132
+
Example:
133
+
variable tTestList as list
134
+
put the empty list into tTestList
135
+
136
+
push "abcd" onto tTestList
137
+
push 1 onto tTestList
138
+
push "xyz" onto tTestList
139
+
push 2 onto tTestList
140
+
141
+
sort tTestList in descending numeric order -- tTestList is [2, 1, "abcd", "xyz"]
142
+
143
+
Description:
144
+
Numeric sort is performed by comparing numeric elements by cardinality. Non-numeric elements come after all numeric elements in the sort order. The sort is stable, so that non-numeric elements are not re-ordered relative to each other.
Copy file name to clipboardExpand all lines: libscript/src/string.mlc
+22-10Lines changed: 22 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -42,7 +42,6 @@ Summary: Prepends <Source> to <Target>.
42
42
Source: An expression which evaluates to a string.
43
43
Target: An expression which evaluates to a string container.
44
44
45
-
Example: put tPrefix before tString
46
45
*/
47
46
48
47
syntax PutStringBefore is statement
@@ -57,7 +56,6 @@ Summary: Appends <Source> to <Target>.
57
56
Source: An expression which evaluates to a string.
58
57
Target: An expression which evaluates to a string container.
59
58
60
-
Example: put tSuffix after tString
61
59
*/
62
60
63
61
syntax PutStringAfter is statement
@@ -75,7 +73,13 @@ Source: An expression which evaluates to a string.
75
73
Target: An expression which evaluates to a string container.
76
74
Replacement: An expression which evaluates to a string.
77
75
78
-
Example: replace " " with "_" in tString
76
+
Example:
77
+
variable tString as string
78
+
put "purple" into tString
79
+
replace "p" with "t" in tString -- tString is "turtle"
80
+
81
+
Description:
82
+
Replaces each occurrence of the string <Pattern> in <Target> with <Replacement>.
79
83
*/
80
84
81
85
syntax ReplaceString is statement
@@ -91,9 +95,11 @@ Summary: Concatenates <Left> and <Right>.
91
95
92
96
Left: An expression which evaluates to a string.
93
97
Right: An expression which evaluates to a string.
94
-
output: String consisting of the value of the left hand expression with the value of the right hand expression appended to the end.
98
+
output: The result of concatenating <Left> and <Right>.
99
+
100
+
Description:
101
+
The result consists of the chars of <Left> followed by those of <Right>.
95
102
96
-
Example: put tLeft & tRight into tConcatenated
97
103
*/
98
104
99
105
syntax ConcatenateStrings is left binary operator with precedence 2
@@ -107,9 +113,10 @@ Summary: Concatenates <Left> and <Right> with a space between.
107
113
108
114
Left: An expression which evaluates to a string.
109
115
Right: An expression which evaluates to a string.
110
-
output: String consisting of the value of the left hand expression with the value of the right hand expression appended to the end, and a space character inserted between them
116
+
output: The result of concatenating <Left> and <Right> with a space between.
111
117
112
-
Example: put tLeft && tRight into tConcatSpace
118
+
Description:
119
+
The result consists of the chars of <Left> followed by a space, and then the chars of <Right>.
113
120
*/
114
121
115
122
syntax ConcatenateStringsWithSpace is left binary operator with precedence 2
@@ -123,7 +130,10 @@ end syntax
123
130
/*
124
131
Summary: Uppercases <Source>.
125
132
Source: An expression which evaluates to a string.
126
-
output:
133
+
output: <Source> with each of its chars uppercased.
134
+
135
+
Description:
136
+
127
137
*/
128
138
129
139
@@ -136,7 +146,9 @@ end syntax
136
146
/*
137
147
Summary: Lowercases <Source>.
138
148
Source: An expression which evaluates to a string.
139
-
output:
149
+
output: <Source> with each of its chars lowercased.
150
+
151
+
Description:
140
152
*/
141
153
142
154
@@ -175,7 +187,7 @@ output: Returns false if the result of evaluating <Left> is the same as that
175
187
*/
176
188
177
189
syntax IsNotEqualTo is neutral binary operator with precedence 1
0 commit comments