c    @(#)sort.f	1.1
c
c
c
      subroutine sort(x,amat,icd)
      include 'qg_par.inc'
      dimension x(icd),amat(k0,k0)
c
c --- routine to sort the floating point array x from greatest to
c --- smallest and arrange the columns of the matrix amat in the same
c --- order as the array x
c
      if(icd.le.1)return
      k=1
   10 continue
      if(k.eq.0) goto 35
      k=0
      do 30 i=2,icd
        if(x(i-1).ge.x(i)) goto 30
        k=1
        temp=x(i-1)
        x(i-1)=x(i)
        x(i)=temp
        do 25 j=1,icd
          temp=amat(j,i-1)
          amat(j,i-1)=amat(j,i)
          amat(j,i)=temp
   25   continue
   30 continue
      goto 10
   35 continue
      return
      end
