Once you have defined the template used to evaluate each message sequence number, you have to create a template to sort these sequence numbers (compareCbMsgSymbols), and another template to retrieve all messages from the communication diagram (description).
The template compareCbMsgSymbols is a boolean that allows verifying if a message number is greater than another message number. The syntax of this template is the following:
.bool (%Item1.Object.SequenceNumber% >= %Item2.Object.SequenceNumber%)
The returned value for this template is used with parameter compare in template description which code is the following:
Communication Scenario %Name%: \n .foreach_item(Symbols,,, %ObjectType% == CommunicationMessageSymbol, %compareCbMsgSymbols%) %Object.description% .next(\n)
In this template, the first line is used to generate the title of the scenario using the name of the communication diagram %Name%. Then it creates a new line.
Then the macro for each item loops on each message symbol, verifies and sorts the message number, and outputs the message description using the syntax defined in previous section.