As per requirement, the input file have 6 kind of records. 1 st clumn of every record is the record type. rectype=1 is header record. record type 2,3,5,7,8 are a set of record in which 2 and 5 have single occurance in a set and 3,7,8 have either single/multipleoccurarances for a set or may not be present at all.
Input file eg.:

Having had your first post Coded, why didn't you do the second one yourself?

Are these "groups" of records delimited by the header=1, or is this an entire file?

You want 1, 2, 5, which must exist, in that order, followed by 3, 7, 8, which may be multiple, or may not even exist in numeric order within this second grouping?

You got any recfm/lrecl for your input and output.

See if you can work out from "stickies" in DFSORT forum how to tell your level of DFSORT.

Process is resonably simple. If 1 2 5, set generated field to a value, else set it to a different value. Sort on that value, then on record type. This is in English, the wizards will have ways to implement.

If this is not an entire file, would need another "key" for the sorting, and would need to know if header is for file or for key.

Are you trying to say that:
1: File will have one record with record type 1
2:Followed by chunk of record types 2 then 3(optional) then 5 then 7 (optional) then 8(optional)
And your are trying to sort records like record type 1(file level) then record type 2 then 5 then optional record types if present like 3,7,8

Please clarify -
1. Always record type 1 will be the first record
2. Second record will be type 2 and the set continues till the next occurance of type 2 record.
3. You want to sort the records between the type2 records? In which you want to follow the order 2,5 and other records in ascending order.

Your assumption is correct.
1. Always record type 1 will be the first record
2. Second record will be type 2 and the set continues till the next occurance of type 2 record.
3.I want to sort the records between the type2 records? In which you want to follow the order 2,5 and other records in ascending order.
I think these will clarify other people doubts too. Thank you

Your assumption is correct.
1. Always record type 1 will be the first record
2. Second record will be type 2 and the set continues till the next occurance of type 2 record.
3.I want to sort the records between the type2 records? In which you want to follow the order 2,5 and other records in ascending order.
I think these will clarify other people doubts too. Thank you

You still havn't told LRECL and RECFM of input file and output file yet

THINKSRINIII
Didnt check if your solution actually works but few quick point I could observe..
1:WHEN=(1,1,CH,NE,C'5',OR,1,1,CH,NE,C'2'),
This is weird
2: Also Why you have added sequence number? Doesn't look you have used anywhere...