New (SortOrder constructor): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
m (misc cleanup)
 
Line 5: Line 5:
Applied as the parameter of a [[Collections|collection]] class [[Collections#Sorting an Arraylist using one sort criterion|sorting method]], an empty <var>SortOrder</var>
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 class="syntaxTable">
<table>
<tr><th>%sortOrder
<tr><th>%sortOrder</th>
</th><td>A <var>SortOrder</var> object variable to contain the new object instance.
<td>A <var>SortOrder</var> object variable to contain the new object instance.</td></tr>
</td></tr>
 
<tr><th nowrap="true"><var>[%(SortOrder For </var>itemType<var>):]</var></th>
<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>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>
</td></tr>
</table>
</table>


==Usage notes==
==Usage notes==
<ul>
<ul>
<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>:
<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>:
<p class="code">%sord = new
<p class="code">%sord = new
   
   
Line 26: Line 27:
%sord = %sord:new
%sord = %sord:new
</p>
</p>
'''Note:'''
<p class="note">'''Note:'''
As shown above, if you explicitly specify the
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]].
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:
<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:
Line 34: Line 35:
</p>
</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)

See also