Tile - Sort Method

Sort the items in the Tile

Member of Tile (PRIM_TILE)

Parameters

NameTypeData TypeDescription
Key*InputVariantValue by which to sort
Order*Input (Optional)EnumerationOrder in which to sort

Details

The Sort method is used to begin the sorting process within the Tile.
 
The processing will cause the OnSort method on the Prim_Tile.TileDesign interface to be executed whenever the sort deems it necessary.
 
Sorting is entirely user defined and it is therefore necessary to supply the Key (the 'value' that is being sorted) and the Order to the sort routine. This information is then used in the OnSort method.

Example

This example shows the redefined OnSort method implemented by the design reusable part.
 
It supports 3 different sorts: EMPNO, SURNAME and GIVENAME. These Key values are entirely arbitrary, but for simplicity they match with specific field names. The sorting here is only ever Ascending.
 
In each case, the local variable value is compared to the equivalent variable value, in this case published as a property of the design instance, to determine whether each value is less then, equal to, or greater than the other.
 
The OnSort method may be called many times for each item as the sort process evaluates each of the items.
Mthroutine Name(OnSort) Options(*Redefine)
 
   Case (#Key)
   When (= EMPNO)
      #Result := #Empno.Compare( (#CompareTo.Design *As #EmployeePart).Empno )
 
   When (= GIVENAME)
      #Result := #Givename.Compare( (#CompareTo.Design *As #EmployeePart).Givename )
 
   When (= SURNAME)
      #Result := #Surname.Compare( (#CompareTo.Design *As #EmployeePart).Surname )
 
   Endcase
 
Endroutine

See also

All Component Classes

Technical Reference

LANSA Version 15, April 2020