How to sort a JSON for a Flex Repeater

Ok, so ill try to keep this brief.

I have a flex repeater that accepts a SQL Query as a Json file. This is my Database query:

select station_number as “StationNum”, “” as “StationState” from stations

I added the “StationState” because I want to sort my Json, so that the repeater puts some of them at the bottom of the list, depending on the value of “StationState”, and the only way I know how to dynamically sort the Flex Repeater is with a Dynamic Json file.

So what ive decided to try to do is use a For repeater to add the values of the Tags to each row of the table, and then sort it. Ive been working on it for a while and just cant come up with the right answer. This is what Ive come up with so far:

pyData = system.dataset.toPyDataSet(value)

for row in range(value.getRowCount()):
	count = row +1
	Tag = system.tag.readBlocking("[default]GoldSim/Station "+ str(count) +"/State tag")
	NewData = system.dataset.setValue(value, row, "StationState", Tag)
return NewData

Is there a easier way to do this? It feels like I’m missing something simple here. Now I think I have to convert the Dataset back to a Json, but im not sure how to do that.

Im quite new to Python and working with Databases/Datasets, so any help would be great.

This implementations looks familiar to me :expressionless:
This is not ethical @user39 , just to do it on your own.

“Clever” I should say, the way you set your username …

1 Like

As @jespinmartin1 stated, no help on the exams.

1 Like

Oh, I didn’t realise it was part of the exam… It’s been a few years :sweat_smile:. @jespinmartin1’s comment was very cryptic unless you knew that detail. Oh well

I guess the hint was in the “GoldSim”

1 Like