Different behaviour in "order by" clause: Oracle vs. PostgreSQL Different behaviour in "order by" clause: Oracle vs. PostgreSQL oracle oracle

Different behaviour in "order by" clause: Oracle vs. PostgreSQL


Postgres has only two built-in collations: C and POSIX. Any other collations are provided by operating system.On many linux systems in UTF locales all non alphanumeric characters are ignored during sorting.

You can obtain expected result using collate C:

select a, length(a) from foo order by a collate "C";

You can find more detailed explanation in this answer.