Talk:Array sort

From Free Pascal wiki
Jump to navigationJump to search

Error in the algorithm

I think the non-generic used algorithm has an error. I wrote about it:,34955.15.html

If you agree, I think it should be changed.

11/11/2021 update I saw no feedback, but the error I still see valid and the fix working, so I changed the Page source code. A full version is now available with more descriptive names on GitHub:

Avoid memory-transfer operations

I think it would be better to use user-supplied swap function instead of relying on low-level memory-transfer operations, e.g.:


    FComp = function ( var data; i, j: integer ): integer;
    FSwap = procedure( var data; i, j: integer );

    TSort = record
        Comp: FComp;
        Swap: FSwap;

procedure Sort( var sort: TSort; var data; left, right: integer );

Antonius (talk) 15:16, 18 February 2018 (CET)