Siebel Reports Administration Guide > Sorting Records in Memory > Examining a Report Sorted on a Multi-Value Field (MVF) >

About the Compare Method on the Sort Data Filter


The Compare method on the sort data filter re-sorts the data rows that have been sent to the filter. A sort filter is configured primarily by overriding the filter's Compare method to specify how the rows should be sorted. Compare takes two rows as arguments and returns one of the following values:

  • A positive number if the first row goes after the second row.
  • Zero if both rows are the same.
  • A negative number if the first row goes before the second row.

The code you define in the Compare method defines the criterion for ordering the records.

The Compare method calls the CompareKeys method (in the AcDataSorter class in the AFC) to compare two key values obtained from the same column. The CompareKeys method returns one of the following values:

  • -1 if key1 is less than key2
  • 0 if key1 equals key2
  • 1 if key1 is greater than key2

In the case of the Opportunities By Sales Rep report, opportunities are being ordered primarily by sales rep and secondarily by revenue. That is, within each group with the same sales rep, the opportunities are ordered by revenue. This makes it possible for the group section to provide a group break at each change in sales rep, and within each group for the opportunities to be listed from highest to lowest in revenue.

The code for the Compare method on the sort data filter is as follows:

Function Compare( row1 As AcDataRow, row2 As AcDataRow ) As Integer

   Dim aRow as CombinedDataRow

   Dim bRow as CombinedDataRow

   Set aRow = row1

   Set bRow = row2

' Order By Sales Reps

   Compare = CompareKeys(aRow.ssSales_Rep, bRow.ssSales_Rep)

' Order by Revenue, descending

' May want to use the functional data here

   If Compare = 0 Then

      Compare = CompareKeys(Val(bRow.ssRevenue), Val(aRow.ssRevenue))

   End If

End Function

Siebel Reports Administration Guide