That is very odd that the values are being sorted as strings, your ternary looks correct from my initial glance.
The one issue might be that from the screen shot it looks like you are in the advanced settings for the whole table. You should be able to click on the specific column name in the inspector panel and then set the format for that column to be numbers.
Let me know if that works!
One other option to get them converted to numbers would be to add that logic into the 'Transform results' block below the query.
You can use some Javascript to grab the values by their row and convert all of them to numbers which should reflect in the table.
Thanks! Formatting the values to Number() in the transformer worked! I couldn't format the individual columns because they're dynamic -- but this is a great solution.