      subroutine reor(n,it,isgn)
      dimension it(n)
      isgn=1
      do 1 i=1,n-1
      do 2 j=i+1,n
      if(it(j).ge.it(i)) goto 2
      isgn=-isgn
      ii=it(i)
      it(i)=it(j)
      it(j)=ii
 2    continue
 1    continue
      return
      end
       subroutine reor8(n,t,io)
      IMPLICIT REAL(8)(A-H,O-X,Z),LOGICAL*1 (Y)
      dimension t(n),io(n)
      do 1 i=1,n-1
      do 2 j=i+1,n
      if((t(j)).ge.(t(i))) goto 2
      tt=t(i)
      t(i)=t(j)
      t(j)=tt
      ii=io(i)
      io(i)=io(j)
      io(j)=ii
 2    continue
 1    continue
      return
      end
       subroutine reorr(n,it,io)
      IMPLICIT REAL(8)(A-H,O-X,Z),LOGICAL*1 (Y)
      dimension it(n),io(n)
      do 1 i=1,n-1
      do 2 j=i+1,n
      if(io(j).gt.io(i).or.(io(j).eq.io(i).and.it(j).ge.it(i))) goto 2
      ii=it(i)
      it(i)=it(j)
      it(j)=ii
      ii=io(i)
      io(i)=io(j)
      io(j)=ii
 2    continue
 1    continue
      do k=1,n
         io(k)=it(k)
      enddo
      return
      end
