diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 2329b7bfb3..60e6e6d6c6 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,11 @@ +19990926-17:22 GMT+1 Victor Szel + * source/rtl/asort.prg + ! The block return type detection code now calls the block with + the nStart item, and not always the first one. This way it has less + side effect, since the block is not called with elements which would not + be accessed at all normally. + So this works now: aSort( { NIL, 20, 10 }, 2,, {|x,y| x < y } ) + 19990926-14:10 GMT+2 Ryszard Glab *source/compiler/harbour.y diff --git a/harbour/source/rtl/asort.prg b/harbour/source/rtl/asort.prg index 70321e92d5..de74ea4f38 100644 --- a/harbour/source/rtl/asort.prg +++ b/harbour/source/rtl/asort.prg @@ -65,9 +65,12 @@ FUNCTION aSort( aArray, nStart, nCount, bBlock ) /* NOTE: For speed we are checking the return type of the passed codeblock here. This will result in a small incompatibility since the codeblock will be called one more time for the - first logical element than in Clipper. */ + first logical element than in Clipper. + But this is block calling frequency and order differs from + Clipper anyway, since they use different sorting sorting + algorhythms. */ - IF !ISBLOCK( bBlock ) .OR. !( ISLOG( Eval( bBlock, aArray[1], aArray[1] ) ) ) + IF !ISBLOCK( bBlock ) .OR. !( ISLOG( Eval( bBlock, aArray[ nStart ], aArray[ nStart ] ) ) ) bBlock := {| x, y | x < y } ENDIF