- the call to TStringList.CustomSort has only one single parameter - the functon to be called by StringList. A pointer to a function with specific signaure. Read any Pascal tutorial about procedure types.
- your function TFrame_Korrelationen.StringListSortComparefn2(List: TStringList; Index1, Index2: Integer): Integer; does not have three paramaeters, it had FOUR parameters. You forgot about Self, which is a parameter too, albeit "hidden" or "invisible" one. This 4th paramneter is exactly why TStringList can not call this your function.
No, that function doesn't have a "hidden" parameter.
The reason for the initial error message is much simpler.
Calling SL_SUB.CustomSort(StringListSortComparefn2) (without the @) in OBJFPC mode, will try to EXECUTE the StringListSortComparefn2 function without any parameters.
Always remember...
With OBJFPC mode you need @ So SL_SUB.CustomSort(@StringListSortComparefn2)
With DELPHI mode you don't need @ So SL_SUB.CustomSort(StringListSortComparefn2)
Second problem, if you use the correct call, is that the sort method can't be part of the class.
The error is then
Incompatible type for arg no. 1: Got "<procedure variable type of function(TStringList;LongInt;LongInt):LongInt of object;Register>", expected "<procedure variable type of function(TStringList;LongInt;LongInt):LongInt;Register>
Just move the StringListSortComparefn2 to outside the class and it will work correctly.
BTW The same goes for Delphi (I just checked). You can't use a class function for the CustomSort call.
You'll get a error "[dcc32 Error] E2009 Incompatible types: 'regular procedure and method pointer'"
So as one of the first post stated.
All you need to do is
1) Use {$MODE DELPHI}{$H+} and move the sort function outside the class.
or
2) use {$MODE OBJFPC}{$H+}, Add the @ in front as required, and move the sort function outside the class.