Talk:Array sort

From Free Pascal wiki
Revision as of 13:35, 14 October 2021 by Jollytall (talk | contribs) (Bug in the proposed algorithm)
Jump to navigationJump to search

Error in the algorithm

I think the non-generic used algorithm has an error. I wrote about it: https://forum.lazarus.freepascal.org/index.php/topic,34955.15.html

If you agree, I think it should be changed.

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.:

interface

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

    TSort = record
        Comp: FComp;
        Swap: FSwap;
    end;

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

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