IRdsElementComparer.Less

Syntax

Less(LValue: IRdsDictionaryElement; RValue:IRdsDictionaryElement): Boolean;

Parameters

LValue, RValue. Sorting elements.

Description

The Less method compares elements that are passed by the LValue and RValue input parameters.

Example

Executing the example requires a form with a button on named Button1, the RdsDictionaryBox component named RdsDictionaryBox1 and the UiRdsDictionary component which is used as a data source for RdsDictionaryBox1.

Add links to the Collections, ForeCollections, Rds system assemblies.

Class IRdsElementComparer_Less_FormForm: Form
    Button1: Button;
    RdsDictionaryBox1: RdsDictionaryBox;
    UiRdsDictionary1: UiRdsDictionary;
    dictionary: IRdsDictionaryInstance;
    LValue, RValue: IRdsDictionaryElement;
    sorter: IRdsElementsSorter;
    com: CustomComparer;
    
Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Begin
    sorter.Sort(
True);
    RdsDictionaryBox1.RefreshElements;
End Sub Button1OnClick;
    

Sub IRDSELEMENTCOMPARER_LESS_FORMFormOnShow(Sender: Object; Args: IEventArgs);
Begin
    com := 
New CustomComparer.Create;
    dictionary := rdsdictionaryBox1.Source.Instance;
    sorter := dictionary.Elements.CreateSorter(dictionary.Elements.Root);
    sorter.Comparer := com 
As IRdsElementComparer;
End Sub IRDSELEMENTCOMPARER_LESS_FORMFormOnShow;

End Class IRdsElementComparer_Less_FormForm;

Class CustomComparer: Object, IRdsElementComparer
    
Function Less(LValue: IRdsDictionaryElement; RValue: IRdsDictionaryElement): Boolean;
    
Var
        comp: IComparer;
    
Begin
        comp := comparer.StringCaseInsensitiveComparer;
        
If (Comp.Compare(LValue.Name, RValue.Name) > 0Then Return True
            
Else Return False;
        
End If;
    
End Function Less;
End Class CustomComparer;

After executing the example pressing the button creates custom sorter of the MDM dictionary elements.

See also:

IRdsElementComparer