        program sorter
c
        character*278 orb
        character*240 meas(8500),meas1
        character*8 ref(8500),ref1
        dimension grade1(8500),grade2(8500)
        character*5 flag(8500),flag1
        character*1 c1
c
        open(10,file='orb6.master.170905',status='UNKNOWN')
        open(11,file='orb6.master.temp2',status='UNKNOWN')
        open(12,file='orb6.master.temp3',status='UNKNOWN')
c
        do 100 n=1,4
        read(10,901) orb
        read(11,901) orb
        write(12,901) orb
  901   format(a278)
  100   continue
c
        nn=0
  200   read(10,902,end=300) meas1,grade11,flag1,ref1,c1
  902   format(a240,t244,f3.1,a5,a8,t1,a1)
        if (c1 .eq. ' ') go to 200
        nn=nn+1
        meas(nn)=meas1
        grade1(nn)=grade11
        grade2(nn)=99.9
        ref(nn)=ref1
        flag(nn)=flag1
        go to 200
c
  300   write(6,991) nn
  991   format(' old catalog read, nn = ',i8)
c
  400   read(11,903,end=999) orb,meas1,grade11,flag1,ref1,c1
  903   format(a278,t1,a240,t244,f3.1,a5,a8,t1,a1)
        if (c1 .eq. ' ') write(12,901) orb
        if (c1 .eq. ' ') go to 400
        do 500 n=1,nn
        if (meas1 .ne. meas(n)) go to 500
        if (ref1 .ne. ref(n)) go to 500
        dgrade=abs(grade1(n)-grade11)
        iflag=0
        if (grade1(n) .eq. 6.0)  iflag=1
        if (grade11   .eq. 6.0)  iflag=1
        if (dgrade    .lt. 0.35) iflag=1
        if (iflag .eq. 1) write(12,901) orb
        if (iflag .eq. 0) write(12,904) orb,grade1(n),grade11,dgrade
  904   format(a278,'  ** ',3f9.1)
        go to 400
  500   continue
        go to 400
c
  999   stop
        end
c
cpairs with dgrade ge 0.4 (out of 8475)                           690
cremove non-keeper orbits from before 2000 with dgrade le 0.5 --> 674


