Skip to main content

ArgSort

ArgSort function performs an indirect heap sort on an array.

It returns the integer array which can be used for obtaining the sorted array.

This function also takes the name of an algorithm as an argument.

Calling example:

ans = ArgSort(x, name)

Interface

  MODULE PURE FUNCTION ArgSort(x, name) RESULT(ans)
INTEGER(Int8|Int16|Int32|Int64), REAL(Real32|Real64), INTENT(IN) :: x(:)
CHARACTER(*), OPTIONAL, INTENT(IN) :: name
INTEGER(I4B) :: ans(SIZE(x))
END FUNCTION ArgSort
  • x is a vector of reals or integers
  • Real64 and Real32 are supported
  • Int8 to Int64 are supported
  • The result is always a vector of integer(I4B).
  • name is optional, and represents the name of the sorting algorithm. Following algorithms are supported
    • HEAPSORT
    • INTROSORT, default
    • INTERSECTION

Examples