      SUBROUTINE SSORT(EX, X, LX, Q, L, OFFSET)
      INTEGER EX, X(LX), Q(L), OFFSET
      EXTERNAL EX
C
C     ENTRIES SPACED 1 APART IN HASH TABLE
C     EX IS EXCHANGE ROUTINE--RETURNS<0 IF EXCHANGES ITEMS
C     RETURNS >=0 IF DOESN'T
C     L  IS NUMBER OF THINGS TO BE SORTED,  SPACING IS 1 HERE
C     START SHELL SORT
C
      M = 1
   10 IF (M.GE.L) GO TO 20
      M = M*2
      GO TO 10
   20 M = M/2
      IF (M.LT.1) RETURN
      K = L - M
C
C      IN PASS1 ARE SORTING SYMBOL TABLE
C      IN PASS 2 ARE SORTING LATTICE
C     OR COMMON BLOCK DEFS
C
      DO 50 J=1,K
        I = J
   30   IF (EX(I+M,I,X,LX,Q,L,OFFSET)) 40, 50, 50
C
C     BUBBLE SORT W/I SUBLIST
C
   40   I = I - M
        IF (I.GE.1) GO TO 30
   50 CONTINUE
      GO TO 20
      END
