	SUBROUTINE SORT (NSEQ,ITEM,KDIM,NORDER)
C	SORT ARRAY ITEM AND STORE SEQUENCE IN ARRAY NSEQ.
C	DIMENSION OF ITEM AND NSEQ IS KDIM.
C	NORDER = +1 IMPLIES INCREASING ORDER.
C	NORDER = -1 IMPLIES DECREASING ORDER.
C
	INTEGER*2 NSEQ(*),IT,KDIM
	REAL ITEM(*),ITEMP
	N=KDIM-1
	DO 50 I=1,N
	  M=I
	  K=I+1
	  IF(NORDER.EQ.1) GO TO 30
	  DO 20 J=K,KDIM
	    IF(ITEM(M).LT.ITEM(J)) M=J
20	  CONTINUE
	  GO TO 45
30	  DO 40 J=K,KDIM
	    IF(ITEM(M).GT.ITEM(J)) M=J
40	  CONTINUE
45	  ITEMP=ITEM(M)
	  ITEM(M)=ITEM(I)
	  ITEM(I)=ITEMP
	  IT=NSEQ(M)
	  NSEQ(M)=NSEQ(I)
	  NSEQ(I)=IT
50	CONTINUE
	RETURN
	END
