Assuming that your both input files are FB recfm with an LRECL of 80 , the following DFSORT JCL will give you the desired results
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
//SORTOUT DD DSN=&&HDR,DISP=(,PASS),SPACE=(TRK,(1,0),RLSE)
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL REMOVECC,HEADER1=('$$$')
//*
//STEP0200 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=&&HDR,DISP=SHR,VOL=REF=*.STEP0100.SORTOUT
// DD DSN=Your first input file,DISP=SHR
// DD DSN=&&HDR,DISP=SHR,VOL=REF=*.STEP0100.SORTOUT
// DD DSN=Your second input file,DISP=SHR
//SORTOUT DD SYSOUT=*
//SYSIN DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(82:SEQNUM,8,ZD,START=4)),
IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'$$$'),PUSH=(81:ID=1)),
IFTHEN=(WHEN=(81,1,ZD,EQ,1),
OVERLAY=(82:82,8,ZD,DIV,+5,M11,LENGTH=8)),
IFTHEN=(WHEN=(81,1,ZD,EQ,2),OVERLAY=(82:SEQNUM,8,ZD,START=0))
SORT FIELDS=(82,8,CH,A),EQUALS
OUTFIL OMIT=(82,8,ZD,EQ,0),BUILD=(1,80)
//*