Can anyone provide guidance for how to sort a List of Dictionaries in an Ignition scrip? I’m using the scripting function system.tag.browseConfiguration and I want to sort the results on the ‘name’ key. I did a little research and found that something like the following should work but it doesn’t:
tagConfig = system.tag.browseConfiguration(UDTtagPath, True)
tagConfigSorted = sorted(tagConfig, key=lambda k: k[‘name’])
I get the error message: ‘com.inductiveautomation.ignition.common.tags.config.TagConfiguration’ object is unsubscriptable
Thank you.
Try
tagConfigSorted = sorted(tagConfig, key=lambda k: k.get('name'))
The ‘unsubscriptable’ error is referring the the square bracket syntax.
1 Like
Because a TagConfiguration
isn't a dictionary.
You beat me to it 
1 Like
Thank you both for the help. I see now that the system.tag.browseConfiguration function returns a list of TagConfiguration objects. The suggested code, however, does not work. The error message is:
TypeError: get(): 1st arg can’t be coerced to com.inductiveautomation.ignition.common.config.Property
How do I replace ‘name’ with a property object called “name”?
Thank you.
In this case I think you can actually use k.getName()
because TagConfiguration
happens to have a getName()
method on it.