C=====================================================================
      SUBROUTINE SORT ( LIST, N )
C
C   Sort a list of integers and remove duplicate entries.
C
      IMPLICIT UNDEFINED (A-Z)
      INTEGER *4 LIST(*), N, I, TEMP, I0, I1
      IF ( N .LE. 1 ) RETURN
      I0 = 1
  100 CONTINUE
          I = I0+1
  200     CONTINUE
              IF ( LIST(I) .EQ. LIST(I0) ) THEN
                  LIST(I) = LIST(N)
                  N = N - 1
              ELSE IF ( LIST(I) .LT. LIST(I0) ) THEN
                  TEMP = LIST(I0)
                  LIST(I0) = LIST(I)
                  LIST(I) = TEMP
                  I = I + 1
              ELSE
                  I = I + 1
              END IF
          IF ( I .LE. N ) GO TO 200
          I0 = I0 + 1
          IF ( I0 .LT. N ) GO TO 100
      RETURN
      END
