I'm trying to sort a text file linewise by their Unicode values. As far as I can tell, this means numerals first, then letters, then CJK-Ideographs. However, sort
(with LC_ALL=C
) fails horribly at this task. Here is an excerpt from my list:
[#ゆうかりんちゃんねる]
[チ→ム♂ツナギ]
[ぞめ]
...
[サディスティックブラウニー]
[ほねとかわとがはなれるおと]
[10th Avenue Cafe]
[2nd Flush]
...
[Alstroemeria Records & Cradle]
[ALTERNATIVE]
[アルトノイラント - Altneuland]
[Amateras Records]
[セブンスヘブンAmmy's]
[anagram]
[Analyze]
...
[Z.S.G TRAXXX]
[α music]
[Яiselied]
[一人華飯スペシャル]
[七瀬屋]
It seems like sort
ignores (at least sometimes) the characters it can't read, because Altneuland
would indeed be between Alternative
and Amateras Records
. Someone suggested using msort
, but it failed as well (with options -u c
, -u d
, and -u n
, respectively).
First, why is it acting so unexpected? Second, how can I fix this?
Add:// I'm using Raspbian on a Raspberry Pi (B)
LC_ALL=C
is for ASCII/7-bit, it's pretty much guaranteed to do the wrong thing for multi-byte characters. Which unicode encoding? (UTF-8, UTF-16, UTF-32, legacy UCS-x?). GNU sort with a correctly set locale is almost certainly up to the task.LC_ALL=C sort
.