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 the Button1 button, the RdsDictionaryBox component named RdsDictionaryBox1, and the UiRdsDictionary component that is a data source for RdsDictionaryBox1.

Class OBJ26217Form: Form
    RdsDictionaryBox1: RdsDictionaryBox;
    UiRdsDictionary1: UiRdsDictionary;
    Button1: Button;
    dictionary: IRdsDictionaryInstance;
    sorter: IRdsElementsSorter;

    Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
    Var
        com: CustomComparer;
    Begin
        com := New CustomComparer.Create;
        sorter := dictionary.Elements.CreateSorter(dictionary.Elements.Root);
        sorter.Comparer := com As IRdsElementComparer;
        sorter.Sort(True);
       RdsDictionaryBox1.RefreshElements;
    End Sub Button1OnClick;

    Sub OBJ26217FormOnShow(Sender: Object; Args: IEventArgs);
    Begin
        dictionary := rdsdictionaryBox1.Source.Instance;
    End Sub OBJ26217FormOnShow;

End Class OBJ26217Form;

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