i have these following data (around 10000 lines or more). I am looking for help with a small program which I can sort the main line and its sublines.

datafile:

M 6 Name: ID 32 Duty, Finished
A
C
E
========================================
M 6 Name: ID 1 Duty, Finished
W
X
Y
Z
========================================
M 6 Name: ID 14 Duty, Finished
K
L
M

There are no telling how many sublines it may have below the main line (ID line 32,1,14) but it is always start with an M. I need it sort with the result below:

M 6 Name: ID 1 Duty, Finished
W
X
Y
Z
M 6 Name: ID 14 Duty, Finished
K
L
M
M 6 Name: ID 32 Duty, Finished
A
C
E

Many thanks!