Using "system.tag.Browse" to create a tag array of full paths

Hi there, I'm having a bit of a nuisance using the tag browse function.

Essentially, I wish to create 2 arrays, one with the full path of my plc tags and one with the values of my client tags. I need these 2 arrays to line up so that I can write all my values at once.

My problem is that, even though both tag folders contain the same amount of tags with the same names, when I browse my Client tag folder the first 2 tags come back out of order (instead of [tag1, tag2...] in the array, it prints [tag2, tag1...]. I don't understand why this is happening, every other tag seems to be in the right order and properly lining up with the PLC tag folder browse.

I'd appreciate any help in the matter, thanks.

This is what my code looks like:

PLCRecipe_Tags = system.tag.browse("[PLC]gstActiveRecipe")
ClientRecipe_Tags = system.tag.browse("[client]ActiveRecipe")

ClientTags =
PLCtags =

for PLCTag_Path in PLCRecipe_Tags.getResults():
tagPath =str(PLCTag_Path["fullPath"])
PLCtags.append(tagPath)

for ClientTag_Path in ClientRecipe_Tags.getResults():
tagPath = str(ClientTag_Path["fullPath"])
ClientTags.append(tagPath)

print(ClientTags)
print(PLCtags)

You could sort both lists after creating them so that you don't depend on the ordering of the browse functions.

Could you refer me to an example of using a sorting function for an array? So far I've found this "system.dataset.sort" but it seems to be used mainly with tables.

Python lists have a sort() method:

>>> a = ["c", "a", "b"]
>>> a.sort()
>>> a
['a', 'b', 'c']

Thank you, this worked! :slight_smile: