List (SortOrder function): Difference between revisions
m (→Syntax terms) |
m (→Syntax terms) |
||
Line 1: | Line 1: | ||
{{Template:SortOrder:List subtitle}} | |||
This shared function is a virtual constructor, or factory method, for SortOrders. | This shared function is a virtual constructor, or factory method, for SortOrders. | ||
Line 14: | Line 8: | ||
List returns are applied consecutively by the sorting method | List returns are applied consecutively by the sorting method | ||
that uses the SortOrder. | that uses the SortOrder. | ||
==Syntax== | |||
{{Template:SortOrder:List syntax}} | |||
===Syntax terms=== | ===Syntax terms=== | ||
<dl> | <dl> | ||
Line 36: | Line 30: | ||
</dl> | </dl> | ||
==Usage notes== | |||
<ul> | <ul> | ||
<li>For more information about factory methods, see [[??]] refid=vconst.. | <li>For more information about factory methods, see [[??]] refid=vconst.. | ||
Line 43: | Line 37: | ||
even if that object is null: | even if that object is null: | ||
<pre> | <pre> | ||
%sord = List(&'italic(sordlist)) | %sord = List(&'italic(sordlist)) | ||
%sord = %(sortorder for float):List(&'italic(sordlist)) | %sord = %(sortorder for float):List(&'italic(sordlist)) | ||
%sord = %sord:List(&'italic(sordlist)) | %sord = %sord:List(&'italic(sordlist)) | ||
</pre> | </pre> | ||
</ul> | </ul> | ||
==Examples== | |||
The typical way to use SortOrder lists is in a Sort or SortNew | The typical way to use SortOrder lists is in a Sort or SortNew | ||
Line 75: | Line 69: | ||
list(ascending(quantity), descending (price))) | list(ascending(quantity), descending (price))) | ||
</pre> | </pre> | ||
==See also== | |||
{{Template:SortOrder:List footer}} |
Revision as of 20:23, 29 June 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
- %sord
- A SortOrder object variable to contain the new object instance.
- %(sortorder for itemtype)
- This optional specification of the class and collection item type in parentheses indicates that the method is shared and does not operate on a specific instance.
- sordlist
- A comma-delimited set of SortOrder objects, which may be explicitly specified Ascending/Descending constructors, 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 like ascending(price) is a single sort criterion, then the maximum number of sort criteria a List call may produce is seven.
Usage notes
- For more information about factory methods, see ?? refid=vconst..
- List is a constructor and as such can be called with no method
object, with an explicit class name, or with an object variable,
even if that object is null:
%sord = List(&'italic(sordlist)) %sord = %(sortorder for float):List(&'italic(sordlist)) %sord = %sord:List(&'italic(sordlist))
Examples
The typical way to use SortOrder lists is in a Sort or SortNew 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)))