Utility Functions : List of Utility Functions : stm_list_sort_by_levels

stm_list_sort_by_levels

Function type: LIST OF ELEMENT

Description
Sorts a list of hierarchical Statemate elements by level.
Note that this function is relevant only for a list of hierarchical elements. If the function is applied to a list of non-hierarchical elements, status receives the value stm_elements_not_hierarchical.
Syntax
stm_list_sort_by_levels (list, status)
Arguments
 

 

Status Codes
Example
Hierarchical elements in a chart can be ordered by levels. See the following statechart:

 

Hierarchically, the states can be drawn as shown as follows:

 

The set of elements, {S1,S2}, comprise a level. Assume you perform a “sort_by_level” function on the states in statechart S. The sorted order would be S, S1, S2, S11.
Note: The order of elements within the same level appear in an arbitrary order in the output. For example, S2 might appear before S1 because they are of the same level. However, the order of levels is “top-to-bottom” (here, S precedes S1 or S2).