Collation order in Rails with Postgresql

Hi,

Hi All!

I am trying to get a rails postgres table ordered by the exact values of
the ascii characters such that:

<none>
Alpha
Bravo
Charlie
...

Unfortunately, even when I try to escape the < characters and enter them
directly in the Postgresql table, I get:

Alpha
Bravo
*
*
*
Lima
Mike
<none>
November
Oscar

I tried @@@@ in place of <none> and it is positioned as I expect, but
@none@ is handled the same as <none>.

I've searched the web, but there are too many different solutions. It
will take me all day and night to try them out,

Can anyone point me in the right direction?

What you want is the C collation[1]. You can either:

- have it during query (`MyModel.order('name COLLATE "C"')`),

- create the column with C collation (`t.string :my_column, :collation
=> "C"` iirc),

- or set default database collation (check either `CREATE DATABASE`
documentation[2] or `initdb`[3]).

[1] http://www.postgresql.org/docs/current/static/collation.html

[2]
http://www.postgresql.org/docs/current/static/sql-createdatabase.html

[3] http://www.postgresql.org/docs/current/static/app-initdb.html