Fix for PostgreSQL ordering