文字列の2D配列を使用するのではなく、TreeMapを使用します。これにより、TreeMapのキーで並べ替えることができます。デフォルトでは、これは自然に順序付けられているため、必要なものがアルファベット順に基づいていますが、トルコ語の文字がアルファベット順にどこにあるかはわかりません。
TreeMap tm = new TreeMap();
// Put elements to the map
tm.put("Zoe Doe", "First entry");
tm.put("Alex Smith", "Second entry");
tm.put("Gareth Baker", "Third entry");
// Get a set of the entries
Set set = tm.entrySet();
// Get an iterator
Iterator i = set.iterator();
// Display elements
while(i.hasNext()) {
Map.Entry me = (Map.Entry)i.next();
System.out.print(me.getKey() + ": ");
System.out.println(me.getValue());
}
これにより、TreeMapの値がアルファベット順に出力されます。
これを変更する必要がある場合は、同等のものを実装して、TreeMapのコンストラクターに渡すことができます。
TreeMap tm = new TreeMap(new Comparator<Foo>()
{
public int compare(Foo f1, Foo f2)
{
return f1.toString().compareTo(f2.toString());
}
});
上記のcompareメソッドに必要なロジックを配置する必要があります。どうやら、標準のアルファベット順とは異なる実装が必要になる場合があります。