pro reorder_path,new_path,option=option,verbose=verbose

;   break path according to operating system
delim = ','
if !version.os eq 'unix'   then delim = ':'
if !version.os eq 'ultrix' then delim = ':'
qq=str2arr(!path,delim)

stype = ['BCS','SXT','GEN','HXT','WBS']

;   loop through, type by type
for jtype =0,4 do begin
if keyword_set(verbose) then print,stype(jtype)

;   find occurrances for this type
   kk = where(strpos(qq,stype(jtype)) ge 0)

;   now look for the subdirectories
   p_rel = where(strpos(qq(kk),'REL') ge 0)
   if p_rel(0) ge 0 then p_rel = p_rel + kk(0)

   p_atest = where(strpos(qq(kk),'ATEST') ge 0)
   if p_atest(0) ge 0 then p_atest = p_atest + kk(0)

   p_contrib = where(strpos(qq(kk),'CONTRIB') ge 0)
   if p_contrib(0) eq -1 then $
      p_contrib = where(strpos(qq(kk),'YUKON') ge 0)
   if p_contrib(0) ge 0 then p_contrib = p_contrib + kk(0)

   p_tobe = where(strpos(qq(kk),'TO_BE') ge 0)
   if p_tobe(0) ge 0 then p_tobe = p_tobe + kk(0)


;   combine subdirectory pointers
   aa = [p_atest,p_rel,p_tobe,p_contrib]

   if keyword_set(option) then begin
      if (strupcase(strmid(option,0,3)) eq 'REV') then begin
         aa = [p_rel,p_atest,p_tobe,p_contrib]
         if jtype eq 0 then $
            print,'** Order of REL and ATEST reversed in !path **
      endif
   endif

;   get rid of cases not found
   naa = where(aa ge 0)
   aa = aa(naa)


   if keyword_set(verbose) then begin
      print,'Present at:',kk
      print,'p_rel    =',p_rel
      print,'p_atest  =',p_atest
      print,'p_contrib=',p_contrib
      print,'p_tobe   =',p_tobe
      print,'Reordered: ',aa
   endif


;   and reoder
   qq(kk) = qq(aa)

endfor

fmt = string('(',n_elements(qq)-1,'(a,1h,),a)',format='(a,i3,a)')
new_path = string(qq,format=fmt)
!path = new_path        ;!!!!

end