Skip to main content

TdxSpreadSheetTableView.SortByRowValues(TRect,TdxSortOrder[],Integer[]) Method

Sorts the specified cell range against multiple rows.

Declaration

procedure SortByRowValues(const AArea: TRect; const ASortOrders: array of TdxSortOrder; const ARows: array of Integer); overload;

Parameters

Name Type
AArea TRect
ASortOrders TdxSortOrder
ARows Integer

Remarks

Call this procedure to sort the call data against multiple rows within the range passed as the AArea parameter. The sort order for each row is specified as the ASortOrders array parameter.

By default, if the first row has several equal values, the corresponding rows are sorted in the order defined by the second element of the ASortOrders and so on. The ARows array of row indexes allows you to customize this sorting sequence, for instance, by putting the third row as the first one to sort, the first row as the second, and so on.

The following image demonstrates the Spreadsheet control with data on countries.

Suppose, you want to sort against the continent and country rows in descending and ascending order, respectively. The following code performs such a sort of the selected cell range. As the values in the third row relate to the data of two previous rows, you must specify all three rows in the sort method. In this example, the selected area is used as the sorting range, thus it is necessary to select all three rows before the code execution.

var
  AArea: TRect;
const
  ASortOrder: array[1..3] of TdxSortOrder =
  (
    soDescending, soAscending, soAscending
  );
  ARows: array[1..3] of Integer = (0, 1, 2);
//...
  AArea := dxSpreadSheet1.ActiveSheetAsTable.Selection.Area;
  dxSpreadSheet1.ActiveSheetAsTable.SortByRowValues(AArea, ASortOrder, ARows);

The result is displayed below.

Note

Invoking the SortByRowValues procedure has no effect if the CanSort method returns False.

See Also