FinalSorting

When a user chooses their own sort criteria, the order of rows can become unpredictable if they choose a column with a lot of duplicates. For example, if they sort Shipments by date and many Shipments have the same date, the system doesn't know to automatically use the Shipment Number as a secondary sort.

Even more importantly, the sort order is used when traveling between multiple pages of report results. This means if you sort only by a column with duplicates, some records may wind up appearing in multiple pages of the report output, or none at all!

To solve this problem, Platform supports a FinalSorting element. When provided, this sort column will be appended to the end of the ORDER BY clause, regardless of the user's preferred sort order. Thus in the previous example, by using SHIPMENT_NUMBER as the FinalSorting, we can ensure that even if we have a hundred Shipments on the same day, they will be displayed in a deterministic order even if sorted by date (since they are sorted secondarily by SHIPMENT_NUMBER). This further ensures they will not be missing or duplicated at report paging boundaries.

FinalSorting supports the following child elements:


  • SortByColumnName—the name of the column (not field) to be sorted.

  • SortDirection—either ASC or DESC, representing ascending and descending order respectively. When omitted, ASC is assumed.

    ...
    </Retrieval>
    <FinalSorting>
    <SortByColumnName>SHIPMENT_NUMBER</SortByColumnName>
    <SortDirection>ASC</SortDirection>
    </FinalSorting>
     
    </Report>

When no FinalSorting is provided, no additional columns are added to the default or user-provided sort criteria.