      PROGRAM SORT
      PARAMETER (LIM=50)
      INTEGER ITEM(LIM), I, N, J, LOCSM, SMALL
      N = 20
      OPEN(1,FILE='oldlst.dat',STATUS='OLD')
      OPEN(2,FILE='newlst.dat',STATUS='NEW')
      DO 10 I = 1,N
        READ(1,*) ITEM(I)
   10 CONTINUE
      DO 20 I = 1, N-1  
        SMALL = ITEM(I)
        LOCSM = I
        DO 30 J = I+1, N
          IF (ITEM(J) .LT. SMALL) THEN
             SMALL = ITEM(J)
             LOCSM = J
          ENDIF
   30   CONTINUE
        ITEM(LOCSM) = ITEM(I)
        ITEM(I) = SMALL
   20 CONTINUE
      WRITE(*,*) (ITEM(I),I=1,N)
      WRITE(2,*) (ITEM(I),I=1,N)
      STOP
      END
