Level 6
Leaving aside the fact that you are encoding data and logic in your query, which is not really a good idea. You could try this:
->orderBy(5,3,'asc)
That might fix your issue.
see this: https://stackoverflow.com/questions/11785622/how-to-use-an-alias-in-a-postgresql-order-by-clause
more generally is to use
->toSQL()
instead of ->get() and that will spit out the SQL you are generating. I sometimes do this and copy the output to a sql editor where I can see what is going on. more clearly