DataObject.Sort

Prototypes

void Sort( Matrix mVarNames <, boolean bAscending> )

void Sort( Matrix mVarNames <, Matrix mDirections> )

void Sort( String sVarName <, boolean bAscending> )

void Sort( String[] asVarNames <, boolean bAscending> )

Parameters

Matrix mVarNames
A vector containing the names of the variables you want to use as sort keys. The primary sort key is variable mVarNames[1], the secondary sort key is variable mVarNames[2], etc.

boolean bAscending
If bAscending is true, the sort key variables are sorted in ascending order. If bAscending is false, the sort key variables are sorted in descending order.

Matrix mDirections
A vector that specifies the sort direction for each sort key variable. If mDirections[i] is 0, the variable mVarNames[i] is sorted in descending order. Otherwise, the variable mVarNames[i] is sorted in ascending order.

String sVarName
The name of the variable to use as the sort key.

String[] asVarNames
An array containing the names of the variables you want to use as sort keys. The primary sort key is variable asVarNames[0], the secondary sort key is variable asVarNames[1], etc.

Remarks

This method sorts the observations in the DataObject according to the data of the specified sort key variables. If neither the bAscending nor the mDirections parameter is specified, the sort key variables are sorted in ascending order.

This method sorts character data linguistically. This means that the values "A", "b", "a", "B" are sorted as "a", "A", "b", "B".

You can control the ordering of a nominal variable's values with the methods DataObject.SetVarSortMode and DataObject.SetVarValueOrder.

Example
mData = { 20 165,
          30 170, 
          40 175, 
          50 180, 
          60 170, 
          70 160 }; 
mVarNames = { "Age", "Weight" };
declare DataObject dobj;
dobj = DataObject.Create( "Sample Data", mVarNames, mData, false );
dobj.Sort( "Weight" );
DataTable.Create( dobj ).ActivateWindow();
See Also

DataObject.SetVarSortMode
DataObject.SetVarValueOrder