finesse.model.Model.sort_elements

Model.sort_elements(key)[source]

Sort the display order of the elements in the model.

This order is used for determining the order of plot traces and other listings.

Element sorting is useful for example when parsing KatScript into a model, where adding of elements to the model may not be performed in the same order as the corresponding definitions in the script. To ensure consistency to the user, this method can be used to sort the parsed elements back into their original script order.

Parameters:
keycallable

Specifies a function that takes a single argument - a tuple containing the element name and object - and returns a comparison key.

Notes

The sort performed by this method is stable.