Issues with Updating Script from Python 2 to Python 3

As the title says, I’ve been attempting to update this script I’m using from Python 2 to Python 3, but keep running into an issue with keys.
I’m running into an error message stating ‘dict_keys’ object has no attribute ‘sort’ whenever it attempts to run Line 192 in the code. Line 191 and 192 state:

Line 191: shapes = CONTROL_SHAPES.keys()
Line 192: shapes.sort()

I have attempted to fix with by by changing 191 to:

shapes = sorted(CONTROL_SHAPES.keys())


shapes = list(CONTROL_SHAPES.keys())

However neither have worked.
I’ve also attempted to rewrite Line 192 as:




However, neither of those have worked either and I was wondering if anyone on here knows what’s going on here and how I can potentially fix this issue.

Have you tried to instead of " shapes = sorted(CONTROL_SHAPES.keys())"
to use “shapes = sorted(list(CONTROL_SHAPES.keys()))