Advanced Customization > Info*Engine User’s Guide > Task Webject Reference > Group Webjects > Sort-Group
  
Sort-Group
DESCRIPTION
Sorts the information in a group of objects by one or more attributes. For example, in a group containing employee names, numbers, and salaries, the Sort-Group webject can be used to specify an alphanumeric ordering of the information by either name, number, salary, or a combination of any or all of the three attributes.
SYNTAX
<ie:webject name="Sort-Group" type="GRP">
  <ie:param name="GROUP_IN" data="input_group_name"/>
  <ie:param name="SORTBY" data="attribute"/>
  <ie:param name="SORTED" data="[ASC | DESC]"/>
  <ie:param name="COMPARISON" data="[ALPHA | NUMERIC]"/>
  <ie:param name="CASE_IGNORE" data="[TRUE | FALSE]"/>
  <ie:param name="CLASS" data="class"/>
  <ie:param name="GROUP_OUT" data="output_group_name"/>
</ie:webject>
PARAMETERS
Required
Select
Optional
GROUP_IN
CASE_IGNORE
GROUP_OUT
CLASS
SORTBY
COMPARISON
SORTED
CASE_IGNORE
Acts as a flag for case. If TRUE is specified, case is ignored. If FALSE is specified, then case is significant. The default for this parameter is FALSE. Multiple values can be specified for this parameter. This parameter is optional.
CLASS
Specifies the type of the objects contained in the output group named by the GROUP_OUT parameter. For example if a webject specifies CLASS=MyClassName and GROUP_OUT=data_1, then the XML representation of the output group contains the following tags:
<MyClassName NAME="data_1" TYPE="Object" STATUS="0">
</MyClassName>
The default for this parameter is “Unknown-Class-Name”. This parameter is optional.
COMPARISON
Describes how to compare the attribute values: either ALPHA for an alpha-numeric comparison or NUMERIC for a strictly numeric comparison. The default for this parameter is ALPHA. Multiple values can be specified for this parameter. This parameter is optional.
GROUP_IN
Specifies the group to be sorted. This parameter is required.
GROUP_OUT
Specifies the name of the sorted group. This parameter is required.
SORTBY
Identifies the field or column name to be used for sorting. Note that null values sort before all numbers and letters in ascending sorting and after all numbers and letters in descending sorting.
Multiple values can be specified for this parameter. If more values are specified for SORTBY than for SORTED, COMPARISON, or CASE_IGNORE, then the last value specified for SORTED, COMPARISON, or CASE_IGNORE is used against the remaining SORTBY values. This parameter is required.
SORTED
Describes how to order the output of the two groups: either ASC for ascending order of output or DESC for a descending order of output. The default of this parameter is ASC. Multiple values can be specified for this parameter. This parameter is optional.
EXAMPLE: SINGLE-COLUMN SORTING
The following example sorts the group named “createdgroup” by name, alphabetically, in ascending order, ignoring case, and places the resulting sorted data in an output group named “results”:
<%@page language="java" session="false"%>
<%@taglib uri="http://www.ptc.com/infoengine/taglib/core" prefix="ie"%>

<!-- Sort the elements in a group. -->

<ie:task uri="com/company/CreateGroup.xml"/>

<ie:webject name="Sort-Group" type="GRP">
  <ie:param name="GROUP_IN" data="createdgroup"/>
  <ie:param name="SORTBY" data="NAME"/>
  <ie:param name="CASE_IGNORE" data="TRUE"/>
  <ie:param name="COMPARISON" data="ALPHA"/>
  <ie:param name="SORTED" data="ASC"/>
  <ie:param name="GROUP_OUT" data="results"/>
</ie:webject>
EXAMPLE: MULTI-COLUMN SORTING
The following Sort-Group webject example shows sorting on multiple columns.
First, a group is created, containing employee last names and department numbers.
<%@page language="java" session="false"%>
<%@taglib uri="http://www.ptc.com/infoengine/taglib/core" prefix="ie"%>

<ie:webject name="Create-Group" type="GRP">
  <ie:param name="ELEMENT" data="DEPT=300:NAME=Smith"/>
  <ie:param name="ELEMENT" data="DEPT=300:NAME=Johnson"/>
  <ie:param name="ELEMENT" data="DEPT=200:NAME=Reilly"/>
  <ie:param name="ELEMENT" data="DEPT=100:NAME=Sinclair"/>
  <ie:param name="ELEMENT" data="DEPT=300:NAME=Michaels"/>
  <ie:param name="ELEMENT" data="DEPT=500:NAME=King"/>
  <ie:param name="GROUP_OUT" data="employees"/>
</ie:webject>

<ie:webject name="Display-Table" type="DSP"/>
The resulting output group named “employees” would display in the following form:
DEPT
NAME
300
Smith
300
Johnson
200
Reilly
100
Sinclair
300
Michaels
500
King
The group “employees” is then sorted by department number, in ascending order.
<ie:webject name="Sort-Group" type="GRP">
  <ie:param name="GROUP_IN" data="employees"/>
  <ie:param name="SORTBY" data="DEPT"/>
  <ie:param name="SORTED" data="ASC"/>
  <ie:param name="GROUP_OUT" data="results"/>
</ie:webject>

<ie:webject name="Display-Table" type="DSP"/>
The output group named “results” would display in the following form:
DEPT
NAME
100
Sinclair
200
Reilly
300
Smith
300
Johnson
300
Michaels
500
King
* 
The employee names in Department 300 are in no particular order.
The group “employees” is then sorted by department number and name, both in ascending order.
<ie:webject name="Sort-Group" type="GRP">
  <ie:param name="GROUP_IN" data="employees"/>
  <ie:param name="SORTBY" data="DEPT,NAME" delim=","/>
  <ie:param name="SORTED" data="ASC"/>
  <ie:param name="GROUP_OUT" data="results"/>
</ie:webject>

<ie:webject name="Display-Table" type="DSP"/>
The output group named “results” would display in the following form:
DEPT
NAME
100
Sinclair
200
Reilly
300
Johnson
300
Michaels
300
Smith
500
King
* 
The employee names in Department 300 are now listed in ascending alphabetical order.
The group “employees” is then sorted by department number, ascending, and name, descending.
<ie:webject name="Sort-Group" type="GRP">
  <ie:param name="GROUP_IN" data="employees"/>
  <ie:param name="SORTBY" data="DEPT,NAME" delim=","/>
  <ie:param name="SORTED" data="ASC,DESC" delim=","/>
  <ie:param name="GROUP_OUT" data="results"/>
</ie:webject>

<ie:webject name="Display-Table" type="DSP"/>
The output group named “results” would display in the following form:
DEPT
NAME
100
Sinclair
200
Reilly
300
Smith
300
Michaels
300
Johnson
500
King
* 
The employee names in Department 300 are now listed in reverse alphabetical order.