Mayur More
Mayur More

Reputation: 981

Sorting strings in Japanese

I am in the process of localizing my android application to Japanese. I have the localized strings. But for example, when displaying a list, I need the strings to be displayed in an alphabetical order.

Is there a way I can sort Japanese strings alphabetically (because all I see is symbols :P).

Upvotes: 4

Views: 2779

Answers (2)

Mena
Mena

Reputation: 48404

  • Use an own Comparator examining code points for hiragana and katakana (and romanji), and pass it as an argument of your sort invocation.
  • For kanji, you're basically on your own, as code points are meaningless for sort operations. It seems like a common issue, if that's any consolation.

Upvotes: 0

agad
agad

Reputation: 2189

Have you tried using collator:

Collator collator = Collator.getInstance(Locale.JAPANESE);
Collections.sort(list, collator);

?

Upvotes: 3

Related Questions