Allow ordering by escaped sql
Fixes #311