Sort data using tag in perspective

Hi Friends,

I’m trying to sort flex repeater in perspective.

I used below code:
value = system.tag.readBlocking("[default]/Tag {Number}/tagone").value
value.sort(key=lambda e: e.Number)
return value

Found below error:
Screenshot (79)

Please can you suggest what is wrong from my side?


How are you setting the string substitution? Seeing your using “{Number}” and based on the error,
replace “value = system.tag.readBlocking(”[default]/Tag {Number}/tagone").value" with
value = system.tag.readBlocking("[default]/Tag %s/tagone"%Number).value

@rbanaszak is correct: {Number} is not a valid string substitution method in Jython. Assuming you have a variable named “Number” then you could do this with a formatted string in Python >=3.0, but not in Jython. His example should work, but I’m more used to something like this:

value = system.tag.readBlocking("[default]/Tag {0}/tagone".format(Number)).value
1 Like