Fixing a bug when sorting on fields containing characters that must be quoted for SQL