Sorted Dictionary Collection - Compare Event

Compare is triggered when two key components need to be compared

Member of Sorted Dictionary Collection (PRIM_SDCO)


NameTypeData TypeDescription
Object*InputPRIM_OBJTObject is the component being compared to
Subject*InputPRIM_OBJTSubject is the component being compared
Result*BothEnumerationResult is the result of the comparison


The Compare event is fired whenever the collection needs to compare two components to determine their relative position.
The Subject and Object parameters contain the two instances to assess.  A result of Greater, Less or Equal must be returned.
If the event is not coded, the collection will compare the two. This effectively uses the memory address of the two collection items.


This example shows the comparison of two customer objects using the Surname property to define the sort order.
This example uses the Compare intrinsic to simplify the code.
Evtroutine Handling(#Customers.Compare) Subject(#Subject) Object(#Object) Result(#Result)
   #Result := #Subject.Surname.Compare(#Object.Surname)

See also

All Component Classes

Technical Reference

LANSA Version 15, April 2020