The SortIndirect attribute function sorts the list by a custom help function.
Syntax | ||||
SortIndirect(SortMethodName) | ||||
Return value | ||||
None | ||||
Parameter | ||||
Use |
Name |
Type |
Passing |
Description |
Required |
SortMethodName |
String |
ByVal |
Name of a help function for sorting. The function must be defined in the same class. |
SortIndirect allows i.e. the sorting of object lists. In that case create a help function for sorting:
Function SortFunc(ByVal P1 As ::Car, ByVal P2 As ::Car) As Long
If P1.Modelname > P2.Modelname Then
SortFunc := 1
ElseIf P1.Modelname = P2.Modelname Then
SortFunc := 0
Else
SortFunc := -1
End If
End Function
The function must be defined with two parameters, matching the Type of the list. The return value must be defined as Long.
The function should
1. Return a value of 1, if the value of the first parameter is greater than the second parameter.
2. Return a value of -1, if the value of the first parameter is lower than the second parameter.
3. Return a value of 0, if the parameters are identical.
In that case the list will be sorted ascending.
The function should
1. Return a value of -1, if the value of the first parameter is greater than the second parameter.
2. Return a value of 1, if the value of the first parameter is lower than the second parameter.
3. Return a value of 0, if the parameters are identical.
In that case the list will be sorted descending.
The sorting will be called by
Cars.SortIndirect("SortFunc")