2013-05-31 53 views
1

默認情況下,Linux排序使用en_US.UTF-8。複製Unix中的Unix排序默認行爲

我試圖找到一個區域設置和Collat​​or,它將重複默認情況下Unix(Linux)排序的工作方式。

有沒有人有任何想法?

  • 試圖在glibc中實現strcoll_l.c似乎不是很有趣。
  • RuleBasedCollat​​or不跟我說話。)

謝謝了。

sl73caeapp03:~ $ cat f 

a 

A 

b 

B 

sl73caeapp03:~ $ sort f # how to duplicate this behavior? 

a 

A 

b 

B 

sl73caeapp03:~ $ LC_ALL=C sort f # not this behavior 

A 

B 

a 

b 
-dreamer

+0

「Linux排序默認使用en_US.UTF-8」。 < - 不。它默認使用'LC_ALL'中定義的語言環境。 – fge

回答

1

你嘗試Locale.US

String[] test = { "A", "a", "B", "b" }; 
Collator order = Collator.getInstance(Locale.US); 
Arrays.sort(test, order); 
for (String s : test) 
    System.out.println(s);