quicksort Derived Type

type, public, extends(sort_base) :: quicksort

class that encapsulates the quicksort algorithm


Inherits

type~~quicksort~~InheritsGraph type~quicksort quicksort type~sort_base sort_base type~quicksort->type~sort_base

Type-Bound Procedures

procedure, public, pass :: sort => quick_sort

  • private recursive subroutine quick_sort(my_sort, list, order)

    main subroutine of the quick sort algorithm.

    Arguments

    Type IntentOptional Attributes Name
    class(quicksort), intent(inout) :: my_sort

    A quicksort object

    real(kind=wp), intent(inout), dimension (:) :: list

    A real vector with the values to be sorted.

    integer, intent(inout), dimension (:) :: order

    An integer vector with the positions of the ordered samples. quick sort routine from: brainerd, w.s., goldberg, c.h. & adams, j.c. (1990) "programmer's guide to fortran 90", mcgraw-hill isbn 0-07-000248-7, pages 149-150. modified by alan miller to include an associated integer array which gives the positions of the elements in the original order.

Source Code

type, extends(sort_base) :: quicksort
!!  class that encapsulates the quicksort algorithm
    contains
        procedure, pass :: sort => quick_sort
end type quicksort