Sorting algorithms/Quicksort: Difference between revisions

Notes about the Fortran algorithm being flawed and a pointer to a better one.
(add RPL)
(Notes about the Fortran algorithm being flawed and a pointer to a better one.)
Line 4,634:
=={{header|Fortran}}==
{{Works with|Fortran|90 and later}}
 
'''WARNING: The implementation of QuickSort in Fortran below is flawed:'''
# If the largest element is in the last slot, the call to QSort(A(marker:),nA-marker+1) goes beyond the end of the array. This can cause exceptions and bad results.
# The use of a random number causes non reproducible performance.
 
'''Instead of this algorithm rather use https://gist.github.com/t-nissie/479f0f16966925fa29ea'''
 
<syntaxhighlight lang="fortran">MODULE qsort_mod
Line 4,690 ⟶ 4,696:
 
CALL QSort(A(:marker-1),marker-1)
CALL QSort(A(marker:),nA-marker+1) WARNING CAN GO BEYOND END OF ARRAY DO NOT USE THIS IMPLEMENTATION
 
END IF
1

edit