Use the following DFSORT JCL which will give you the desired results.
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
----+----1----+----2----+----3----+----4----+
121,1234567; 121,34;
333,12367; 2,34;
,03367; 12,12;
5000; 1,1;
,1; 20,2;
1,4562345; 15;
735;,24;
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=(1,19,SS,EQ,C',',AND,20,19,SS,EQ,C','),
PARSE=(%01=(ENDBEFR=C',',FIXLEN=18),
%02=(ENDBEFR=C';',FIXLEN=07),
%03=(ENDBEFR=C',',FIXLEN=18),
%04=(ENDBEFR=C';',FIXLEN=02)),
BUILD=(%01,UFF,M11,LENGTH=18,C',',
%02,TRAN=ALTSEQ,C';',
%03,UFF,M11,LENGTH=18,C',',
%04,TRAN=ALTSEQ)),
IFTHEN=(WHEN=(1,19,SS,NE,C',',AND,20,19,SS,EQ,C','),
PARSE=(%05=(STARTAT=C'0',STARTAT=C'1',STARTAT=C'2',STARTAT=C'3',
STARTAT=C'4',STARTAT=C'5',STARTAT=C'6',STARTAT=C'7',
STARTAT=C'8',STARTAT=C'9',ENDBEFR=C';',FIXLEN=07),
%06=(ENDBEFR=C',',FIXLEN=18),
%07=(ENDBEFR=C';',FIXLEN=02)),
BUILD=(18C'0',C',',
%05,TRAN=ALTSEQ,C';',
%06,UFF,M11,LENGTH=18,C',',
%07,TRAN=ALTSEQ)),
IFTHEN=(WHEN=(1,19,SS,EQ,C',',AND,20,19,SS,NE,C','),
PARSE=(%08=(ENDBEFR=C',',FIXLEN=18),
%09=(ENDBEFR=C';',FIXLEN=07),
%10=(ENDBEFR=C';',FIXLEN=18)),
BUILD=(%08,UFF,M11,LENGTH=18,C',',
%09,TRAN=ALTSEQ,C';',
%10,UFF,M11,LENGTH=18,C',',
2C'0'))
ALTSEQ CODE=(40F0)
//*