!+ Subroutine to reorder the exponents in an ESFT fit.
!
! Method:
!	Each exponent is compared with its successor and interchanged
!	if necessary so that all expoents are in increasing order.
!
! Current Owner of Code: J. M. Edwards
!
! History:
!	Version		Date			Comment
!	1.0		12-04-95		First Version under RCS
!						(J. M. Edwards)
!
! Description of Code:
!   FORTRAN 77  with extensions listed in documentation.
!
!- ---------------------------------------------------------------------
      SUBROUTINE REORDER(N_TERM, K, A)
!
!
!
      IMPLICIT NONE
!
!
!     INCLUDE HEADER FILES.
      INCLUDE 'incl/dimensions_spec.ucf'
      INCLUDE 'incl/dimensions_pp.ucf'
!
!     DUMMY VARIABLES.
      INTEGER 	!, INTENT(IN)
     &     N_TERM                           
!             NUMBER OF TERMS
      REAL*8 	!, INTENT(INOUT)
     &     K(NPD_ESFT_TERM)                   
!             ESFT EXPONENTS
     &   , A(NPD_ESFT_TERM)                   
!             ESFT WEIGHTS
!
!     LOCAL VARIABLES.
      INTEGER
     &     I                                
!             LOOP VARIABLE
     &   , J
!             LOOP VARIABLE
      REAL*8
     &     K_TEMPORARY   
!             TEMPORARY EXPONENT
     &   , A_TEMPORARY                      
!             TEMPORARY WEIGHT
!
!
!     TAKE THE ELEMENTS OF K ONE BY ONE AND PLACE THEM LOWER IN
!     THE ORDER IF THEY ARE SMALL. MAKE THE SAME CHANGES TO THE A'S.
      DO I=2, N_TERM
         K_TEMPORARY=K(I)
         A_TEMPORARY=A(I)
         DO J=I-1, 1, -1
            IF (K(J).LE.K_TEMPORARY) GOTO 3
            K(J+1)=K(J)
            A(J+1)=A(J)
         ENDDO
         J=0
3        K(J+1)=K_TEMPORARY
         A(J+1)=A_TEMPORARY
      ENDDO
!
!
      RETURN
      END
