      SUBROUTINE IVOLG(X,N,MX,IX,UP)
*
*---- Volgorde bepalen van X
*
*---- J.P.M. Witte, Augustus 1994
*
      PARAMETER(NV=10000)
*
      REAL X(N)
      INTEGER IX(N)
      LOGICAL V(NV),UP
*
      IF (MX.GT.NV) STOP 'NV in subrtn IVOLG te klein'
*
      DO 10 I=1,MX
         V(I)=.FALSE.
10    CONTINUE
      DO 30 I=1,MX
         XMX=999999999.
         XMN=-999999999.
         DO 20 J=1,MX
            IF (.NOT.V(J).AND.((UP.AND.X(J).LT.XMX).OR.
     #      (.NOT.UP.AND.X(J).GT.XMN))) THEN
              XMX=X(J) 
              XMN=X(J)
              JMX=J
            END IF
20       CONTINUE
         IX(I)=JMX
         V(JMX)=.TRUE.
30    CONTINUE
*
      RETURN
      END
