postgresでvarcharのソート順が文字列ソートじゃなくて数値ソートみたいになっていた。
collate "C"
をorder句に追加すればバイトオーダーでソートしてくれ、意図した順にソートされた。
postgres=# select name from test order by name; name ------ あ い ああ いい (4 rows) postgres=# select name from test order by name collate "C"; name ------ あ ああ い いい (4 rows)続きを読む