Change cell colors and Re-ordering my table in Perspective

I have 3 tables in my database. Using a Select query I have fetched necessary columns and binded it to a param"Data" on my view, my data set is then converted to dictionary , added 5 columns with arithmetic calculations through scripting.
I tried a script that works in Pycharm and reorders my list but won't work within script transform in my table

I now need to change color of some of my cells according to a Color Reference column in my Dataset. I also need to reorder my columns before returning my script

Any ideas how. Thanks

The link will take you to the examples at the bottom of the document.

I also need to reorder my columns ...

Do that in the SQL using ORDER BY ...