Order by where conditions SELECT * FROM table
WHERE
key REGEXP 'some long regular expression'
OR key REGEXP 'some other long regular expression'

ORDER BY
key REGEXP 'some long regular expression' DESC,
key REGEXP 'some other long regular expression' DESC


Is there a cleaner way to get the same result as above, without repeating the where conditions in order by?
Use a subquery, something like:

SELECT * FROM (
  SELECT
    t.*,
    key REGEXP 'some long regular expression' AS a,
    key REGEXP 'some other long regular expression' AS b
  FROM table t
  WHERE a OR b
)
ORDER BY a DESC, b DESC;