New (SortOrder constructor): Difference between revisions
Jump to navigation
Jump to search
m (1 revision) |
m (misc cleanup) |
||
(12 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{Template:SortOrder:New subtitle}} | {{Template:SortOrder:New subtitle}} | ||
The <var>SortOrder</var> instance created by <var>New</var> is empty, that is, without a | |||
The SortOrder created by New is empty, that is, without a | |||
sorting order or sorting key. | sorting order or sorting key. | ||
Applied as the parameter of a | Applied as the parameter of a [[Collections|collection]] class [[Collections#Sorting an Arraylist using one sort criterion|sorting method]], an empty <var>SortOrder</var> | ||
produces a copy of the input collection. | produces a copy of the input collection. | ||
==Syntax== | ==Syntax== | ||
{{Template:SortOrder:New syntax}} | {{Template:SortOrder:New syntax}} | ||
===Syntax terms=== | ===Syntax terms=== | ||
<table | <table> | ||
<tr><th | <tr><th>%sortOrder</th> | ||
< | <td>A <var>SortOrder</var> object variable to contain the new object instance.</td></tr> | ||
</td></tr></table> | |||
<tr><th nowrap><var>[%(SortOrder For </var>itemType<var>):]</var></th> | |||
<td>The optional class name in parentheses denotes a <var>[[Notation conventions for methods#Constructors|Constructor]]</var>. See [[#Usage notes|Usage notes]], below, for more information about invoking a <var>SortOrder</var> <var>Constructor</var>. </td></tr> | |||
</table> | |||
==Usage notes== | ==Usage notes== | ||
<ul> | <ul> | ||
<li>New | <li>As described in [[Object variables#Using New or other Constructors|Using New or other Constructors]], <var>New</var> can be invoked with no object, with an explicit class specification, or with an object variable in the class, even if that object is <var>Null</var>: | ||
with an explicit class | <p class="code">%sord = new | ||
that object is | |||
<p class="code" | |||
%sord = %( | %sord = %(SortOrder for object stringlist):new | ||
%sord = %sord:new | %sord = %sord:new | ||
</p> | |||
%arraylist2 = %arraylist1:sortnew(new) | <p class="note">'''Note:''' | ||
As shown above, if you explicitly specify the | |||
class name, you must include the item datatype of the collection to be sorted, just as on a <var>SortOrder</var> object variable's [[SortOrder class#Declaring a SortOrder object variable|declaration]]. </p> | |||
<var>New</var> can also be invoked directly as a parameter of a <var>[[Sort (Arraylist subroutine)|Sort]]</var> subroutine or <var>[[SortNew (GenericNamedArraylist function)|SortNew]]</var> function: | |||
<p class="code">%arraylist2 = %arraylist1:sortnew(new) | |||
</p> | |||
</ul> | </ul> | ||
==See also== | ==See also== | ||
{{Template:SortOrder:New footer}} | {{Template:SortOrder:New footer}} |
Latest revision as of 16:09, 6 April 2015
Create a new, null SortOrder (SortOrder class)
The SortOrder instance created by New is empty, that is, without a
sorting order or sorting key.
Applied as the parameter of a collection class sorting method, an empty SortOrder
produces a copy of the input collection.
Syntax
%sortOrder = [%(SortOrder For itemType):]New
Syntax terms
%sortOrder | A SortOrder object variable to contain the new object instance. |
---|---|
[%(SortOrder For itemType):] | The optional class name in parentheses denotes a Constructor. See Usage notes, below, for more information about invoking a SortOrder Constructor. |
Usage notes
- As described in Using New or other Constructors, New can be invoked with no object, with an explicit class specification, or with an object variable in the class, even if that object is Null:
%sord = new %sord = %(SortOrder for object stringlist):new %sord = %sord:new
Note: As shown 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.
New can also be invoked directly as a parameter of a Sort subroutine or SortNew function:
%arraylist2 = %arraylist1:sortnew(new)