Sort method: Rowset class

Syntax

Sort([paramlist,] sort_fields)

Where paramlist is a list of child rowsets, given in the following form:

SCROLL.scrollname1 [, SCROLL.scrollname2] .  .  .

The first scrollname must be a child rowset of the rowset executing the method, the second scrollname must be a child of the first child, and so on.

And where sort_fields is a list of field specifiers in the form:

[recordname.]field_1, order_1 [, [recordname.]field_2, order_2]_

Description

Sort programmatically sorts the rows in a rowset. The rows can be sorted on one or more fields.

If you specify a child rowset in paramlist, Sort selects a set of child rowsets to be sorted. If you don’t specify a child rowset in paramlist, the rowset executing the method is sorted.

The type of sort done by this function, that is, whether it is a linguistic or binary sort, is determined by the Sort Order Option on the PeopleTools Options page.

Note:

The Sort method sorts only visible rows in a rowset. If the rowset you're sorting has hidden rows, the hidden rows are not sorted. Rows marked for deletion are also not sorted.

Parameters

Parameter Description

paramlist

An optional parameter list, for specifying children rowsets of the rowset executing the method, as the rowset to be sorted. The first scrollname in paramlist must be a child rowset of the rowset executing the method, the second scrollname must be a child of the first child, and so on.

sort_fields

A list of field and order specifiers which act as sort keys. The rows in the rowset will be sorted by the first field in either ascending or descending order, then by the second field in either ascending or descending order, and so on.

[recordname.]field_n

Specifies a sort key field in the rowset. The recordname prefix is required if you’ve specified a field that is not on the current record.

order_n

A single-character string. "A" specifies ascending order; "D" specifies descending order.

Returns

None.

Example

The first example repopulates a rowset in a page programmatically by first flushing its contents, selecting new contents using Select, then sorting the rows in ascending order by EXPORT_OBJECT.NAME:

Function populate_rowset;

   &RS1 = GetLevel0()(1).GetRowset(Scroll.EXPORT_OBJECT);
   &RS1.Flush();
   &RS1.Select(Record.EXPORT_OBJECT, "where export_type =:EXPORT_TYPE_VW.EXPORT_TYPE");
   &RS1.Sort(EXPORT_OBJECT.NAME, "A");

End-Function;