Info
Content

Rowset Sorting


The Rowset class includes a Sort method which can be used to sort items in the Rowset by one or more fields in ascending or descending order. Very much like what the order by clause does for you in SQL.

PeopleBooks gives an example of how to sort by a single field. To sort by multiple fields, add each record.field and order to the parameter list. For example:

&rs.Sort(RECORD.FIELD1, "A", RECORD.FIELD2, "D", RECORD.FIELD3, "A");

So this example will sort by FIELD1 (asecending) then FIELD2 (descending) and then FIELD3 (ascending). Pretty much the same as an order by syntax but you do need to be explicit about the sort format (A=ascending, D=descending).

NOTE: A filled rowset won't necessarily take the ordering you specify in your SQL or in a view. So you might go to the trouble of ordering in the view/SQL and it will probably revert to ordering the data in the sequence in which it was entered in the database. So you'll need to use the Rowset sort method in this scenario.
No Comments
Back to top