canonical to idoc


i am mapping canonical to IDOC,i have strucked at one place.
i will explain req first, sap guys need an idoc in a formate like
as in one segment they need
flag number
y 3.3
n 3.1
n 3.5
y 2.1
n 2.5
n 2.3
what they need is if flag is Y it should come on top and the respective numbers like(sequence of number 3) 3.3, 3.2,3.7 should come directly under the flag field…need help from gigs