*************************************************************
* sort, using temporary output file and unix system call
! CREATED: Julia Lee-TAYLOR, NCAR                 !

      SUBROUTINE sortunix(ns,s)
      IMPLICIT NONE
      INCLUDE 'general.h'

* input/output      
      INTEGER    ns
      CHARACTER(LEN=lco) s(ns)
* internal
      INTEGER    ifort,i
      PARAMETER(ifort=8)

      print*,"*sortunix*",ns

      OPEN(ifort,file='sortlist.old',status='REPLACE')
      DO i=1,ns
        WRITE(ifort,'(A6)') s(i)
      ENDDO
      CLOSE(ifort)

      CALL system('sort sortlist.old -o sortlist.new')

      OPEN(ifort,file='sortlist.new')
      DO i=1,ns
        READ(ifort,*) s(i)
      ENDDO
      CLOSE(ifort)

      RETURN
      END
