New (SortOrder constructor): Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
m (misc cleanup)
 
(11 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Template:SortOrder:New subtitle}}
{{Template:SortOrder:New subtitle}}
   
   
This method creates a new instance of the <var>SortOrder</var> class.
The <var>SortOrder</var> instance created by <var>New</var> is empty, that is, without a
The <var>SortOrder</var> created by <var>New</var> is empty, that is, without a
sorting order or sorting key.
sorting order or sorting key.
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><var>%(SortOrder For</var> itemtype)</th>
<tr><th nowrap><var>[%(SortOrder For </var>itemType<var>):]</var></th>
<td>This optional specification of the class in parentheses indicates that the method is shared and does not operate on a specific instance. If you use this option, however, you must include the collection item type to which the selection expression will be applied, like this: <code>%(SortOrder For <i>itemtype</i>):</code> </td></tr>
<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>
</table>


==Usage notes==
==Usage notes==
<ul>
<ul>
<li><var>New</var> is a constructor and as such can be called with no object,
<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
name and collection item type, or with an object variable, even if
that object is null:
<p class="code">%sortOrder = new
   
   
%sortOrder = %(sortOrder for object stringlist):new
%sord = %(SortOrder for object stringlist):new
   
   
%sortOrder = %sortOrder: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>
</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