TABLE OF CONTENTS
/sorting [ Modules ]
This module defines some routines for sorting purposes
sorting/indexx [ Subroutines ]
Indexes an array arr, i.e., outputs the array index of length N such that arr(index(j)) is in ascending order for j = 1, 2, . . . ,N. The input quantity arr is not changed.
(Uses SORTTF from CernLib; cf. SORTZV)
- real, dimension(:) :: arr
- integer, dimension(:) :: index
the integer array "index" has to be provided as input. The size may not be smaller than the size of "arr"
Assume you have to arrays A and B and you want to access the information first in an unsorted way and secondly sorted according the values of array A.
do i=1,n write(*,*) A(i),B(i) ! unsorted enddo call indexx(A,ii) do i=1,n write(*,*) A(ii(i)),B(ii(i)) ! sorted according A enddo