Callback for Sorting-commands to allow custom sorting orders
Posted: Mon Jul 27, 2009 12:11 am
Hello!
What do you think of the idea to implement the possibility for a callback for all the sorting commands in order to allow the coder to use its own order?
Example:
The callback should return -1, 0 or 1 for lower, equal or greater results.
The new syntax for SortList(), for example could beWhereas it could be 0 to leave it out while using Start/End scope.
What do you think of the idea to implement the possibility for a callback for all the sorting commands in order to allow the coder to use its own order?
Example:
Code: Select all
Procedure callback(a, b)
; your own algorithm goes here
If a < b
ProcedureReturn #PB_String_Lower ; -1
ElseIf a = b
ProcedureReturn #PB_String_Equal ; 0
Else
ProcedureReturn #PB_String_Greater ; 1
EndIf
EndProcedure
SortList(myList(), #PB_Sort_Ascending, @callback())
The new syntax for SortList(), for example could be
Code: Select all
SortList(ListName(), Options [, @Callback() [, Start, End]])