FNLMath : Utilities : SVIBN
SVIBN
Sorts an integer array by nondecreasing absolute value.
Required Arguments
IA — Integer vector of length N containing the array to be sorted. (Input)
IB — Integer vector of length N containing the sorted array. (Output)
If IA is not needed, IA and IB can share the same storage locations.
Optional Arguments
N — Number of elements in the array to be sorted. (Input)
Default: N = size (IA,1).
FORTRAN 90 Interface
Generic: CALL SVIBN (IA, IB [])
Specific: The specific interface name is S_SVIBN.
FORTRAN 77 Interface
Single: CALL SVIBN (N, IA, IB)
Description
Routine SVIBN sorts the elements of an integer array, A, into ascending order by absolute value. This routine SVIBN uses the algorithm discussed in SVRGN. On completion, Aj  Ai for j < i.
Example
This example sorts the 10-element array IA by absolute value.

USE SVIBN_INT
USE UMACH_INT

IMPLICIT NONE
! Declare variables
INTEGER I, J, NOUT, N

! Set values for IA
! IA = ( -1 3 -4 2 -1 0 -7 6 10 -7)
!
DATA IA/-1, 3, -4, 2, -1, 0, -7, 6, 10, -7/
! Sort IA by absolute value into IB
CALL SVIBN (IA, IB)
! Print results
CALL UMACH (2,NOUT)
WRITE (NOUT, 99999) (IB(J),J=1,N)
!
99999 FORMAT (' The output vector is:', /, 10(1X,I5))
END
Output

The Output vector is:
0 -1 -1 2 3 -4 6 -7 -7 10