How do I change the sort ordering of textual data?
How do I change the sort ordering of textual data?
PostgreSQL sorts textual data according to the ordering that is defined by the current locale, which is selected during initdb. It is possible to select a different locale when creating a new database. You can also assigns a collation to the column (which must be of a collatable data type) when creating a new table, or adding a new column to the table, or changing the type of a column of a table. If you don’t like the ordering then you need to use a different locale. In particular, most locales other than C
sort according to dictionary order, which largely ignores punctuation and spacing. If that’s not what you want then you need C
locale.