Use an indirect introspection sort on an array of numbers
Example usage
program argSortTest use variableKind use m_strings, only: str use m_random, only: rngInteger, rngNormal use m_arrays, only: arange, isSorted use m_Sort, only: argSort real(r64),allocatable :: d1D(:) integer(i32),allocatable :: i1D(:) integer(i32),allocatable :: indx(:) integer(i32) :: i, N N=10000 call allocate(indx, N) call arange(indx, 1, N) call allocate(d1D, N) call rngNormal(d1D) call argSort(d1D, indx) write(*,'(a)') 'Double array is indirectly sorted? '//str(isSorted(d1D(indx))) call arange(indx, 1, N) call allocate(i1D,N) call rngInteger(i1D) call argSort(i1D, indx) write(*,'(a)') 'Integer array is indirectly sorted? '//str(isSorted(i1D(indx))) end program
Interfaced with argSort
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=i32) | :: | this(:) | 1D array |
|||
integer(kind=i32) | :: | i(:) | Index to sort |
|||
logical, | optional | :: | stable | Stable sort? |
Interfaced with argSort
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=i64) | :: | this(:) | 1D array |
|||
integer(kind=i32) | :: | i(:) | Index to sort |
|||
logical, | optional | :: | stable | Stable sort? |
Interfaced with argSort
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=r32) | :: | this(:) | 1D array |
|||
integer(kind=i32) | :: | i(:) | Index to sort |
|||
logical, | optional | :: | stable | Stable sort? |
Interfaced with argSort
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=r64) | :: | this(:) | 1D array |
|||
integer(kind=i32) | :: | i(:) | Index to sort |
|||
logical, | optional | :: | stable | Stable sort? |