!+ Subroutine to order a list of transmissions by amount of absorber.
!
! Method:
!	The shell sorting technique is used to order the pairs
!	of transmissions and amounts in order of increasing amount.
!
! 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 ORDER_SET(L_DENSITY
     &   , LENGTH_SET, DEN_SET, U_SET, TRANS_SET
     &   )
!
!
      IMPLICIT NONE
!
!
!     INCLUDE HEADER FILES
      INCLUDE 'incl/dimensions_pp.ucf'
!
!     DUMMY ARGUMENTS
      INTEGER	!, INTENT(IN)
     &     LENGTH_SET
!             LENGTH OF SETS
      LOGICAL	!, INTENT(IN)
     &     L_DENSITY
!             CONTINUUM FLAG
      REAL*8	!, INTENT(INOUT)
     &     DEN_SET(NPD_AMOUNT)
!             DENISTY OF SPECIES
     &   , U_SET(NPD_AMOUNT)
!             AMOUNTS OF ABSORBERS
     &   , TRANS_SET(NPD_AMOUNT)
!             TRANSMITTANCES IN SETS
!
!     LOCAL VARIABLES.
      INTEGER
     &     GAP
!             INTERVAL IN SHELL SORT
     &   , J
!             LOOP VARIABLE
     &   , K
!             LOOP VARIABLE
      REAL*8
     &     DEN_TEMP
!             TEMPOARY DENSITY
     &   , U_TEMP
!             TEMPORARY AMOUNT
     &   , TR_TEMP
!             TEMPORARY TRANSMISSION
!
!
!     SORT THE ELEMENTS USING THE SHELL SORT TECHNIQUE.
!
      IF (LENGTH_SET.EQ.1) RETURN
!
      GAP=LENGTH_SET
1     GAP=GAP/2
         DO J=GAP, LENGTH_SET-1
            DO K=J-GAP+1, 1, -GAP
               IF (U_SET(K).GT.U_SET(K+GAP)) THEN
                  IF (L_DENSITY) THEN
                     DEN_TEMP=DEN_SET(K)
                     DEN_SET(K)=DEN_SET(K+GAP)
                     DEN_SET(K+GAP)=DEN_TEMP
                  ENDIF
                  U_TEMP=U_SET(K)
                  U_SET(K)=U_SET(K+GAP)
                  U_SET(K+GAP)=U_TEMP
                  TR_TEMP=TRANS_SET(K)
                  TRANS_SET(K)=TRANS_SET(K+GAP)
                  TRANS_SET(K+GAP)=TR_TEMP
               ENDIF
            ENDDO
         ENDDO
      IF (GAP.GE.2) GOTO 1

!
      RETURN
      END
