Difference between revisions of "Talk:Array sort"

From Free Pascal wiki
Jump to navigationJump to search
(Bug in the proposed algorithm)
 
Line 5: Line 5:
  
 
If you agree, I think it should be changed.
 
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: https://github.com/zsoltszakaly/quicksortforpascal
  
 
== Avoid memory-transfer operations ==
 
== Avoid memory-transfer operations ==

Latest revision as of 09:10, 11 November 2021

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.

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: https://github.com/zsoltszakaly/quicksortforpascal

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)