List (SortOrder function): Difference between revisions
mNo edit summary |
m (→Syntax terms) |
||
Line 17: | Line 17: | ||
<td>For a shared function, this optional specification of the class in parentheses [[Notation conventions for methods#Shared methods|denotes a virtual constructor]]. See [[#Usage notes|"Usage notes"]], below, for more information about invoking a <var>SortOrder</var> virtual constructor. </td></tr> | <td>For a shared function, this optional specification of the class in parentheses [[Notation conventions for methods#Shared methods|denotes a virtual constructor]]. See [[#Usage notes|"Usage notes"]], below, for more information about invoking a <var>SortOrder</var> virtual constructor. </td></tr> | ||
<tr><th>sortOrderItems</th> | <tr><th>sortOrderItems</th> | ||
<td>A comma-delimited set of <var>SortOrder</var> objects, which may be explicitly specified [[Ascending and Descending (SortOrder functions)|Ascending/Descending | <td>A comma-delimited set of <var>SortOrder</var> objects, which may be explicitly specified [[Ascending and Descending (SortOrder functions)|Ascending/Descending]] functions, | ||
<var>SortOrder</var> object variables, or another <var>SortOrder</var> <var>List</var> specification. | <var>SortOrder</var> object variables, or another <var>SortOrder</var> <var>List</var> specification. | ||
These individual <var>SortOrders</var> are applied to the target collection items | These individual <var>SortOrders</var> are applied to the target collection items |
Revision as of 19:13, 1 August 2011
Create a composite SortOrder (SortOrder class)
This shared function is a virtual constructor, or factory method, for SortOrders.
The List
method invokes the creation of a new SortOrder instance, then populates that
instance with items from an input list that are themselves SortOrder instances.
Designed for specifying multiple sort criteria, the SortOrders in the object that
List returns are applied consecutively by the sorting method
that uses the SortOrder.
Syntax
%sortOrder = [%(SortOrder For itemType):]List( sortOrderItems)
Syntax terms
%sortOrder | A SortOrder object variable to contain the new object instance. |
---|---|
%(SortOrder For itemtype) | For a shared function, this optional specification of the class in parentheses denotes a virtual constructor. See "Usage notes", below, for more information about invoking a SortOrder virtual constructor. |
sortOrderItems | A comma-delimited set of SortOrder objects, which may be explicitly specified Ascending/Descending functions,
SortOrder object variables, or another SortOrder List specification. These individual SortOrders are applied to the target collection items in the order they are specified in this argument. If a SortOrder likeascending(price) is a single sort criterion, then the maximum number of sort criteria a List call may produce is seven. |
Usage notes
- List is a virtual constructor and as such can be invoked with no method
object, with an explicit class specification, or with an object variable of the class,
even if that object is Null:
%sord = List(sortOrderItems) %sord = %(Sortorder for float):List(sortOrderItems) %sord = %sord:List(sortOrderItems)
Note: As shown in the second of these above, if you explicitly specify the class name, you must include the item datatype of the collection to be sorted, just as on a SortOrder object variable's declaration.
Examples
The typical way to use SortOrder lists is in a collection class sorting method invocation:
%orders:sort(%myorder)
Where, for example:
%myorder = list(ascending(quantity), descending(price))
Since the arguments to the SortOrder List method are also SortOrders, you could
also pass the %myorder
variable in another List call.
The following List statement
inserts the %myorder
criteria into the middle of two other sort criteria:
%mynewOrder = list(ascending(length), %myorder, descending(reverse))
You can even pass a List call within a List call:
%myorder = list(ascending(change), list(ascending(quantity), descending (price)))