Subroutine to sort (inplace) using the quick sort algorithm. Adapted from http://www.fortran.com/qsort_c.f95.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=pfqp), | intent(inout) | :: | a(:) |
recursive subroutine qsort(a)
real(pfqp), intent(inout) :: a(:)
integer :: iq
if (size(a) > 1) then
call qsort_partition(a, iq)
call qsort(a(:iq-1))
call qsort(a(iq:))
end if
end subroutine qsort