Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

sorting in Chinese

hila sharabi
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to sort list of chinese countries (for example) but the order does not come out right. Here is a sample of my code. I am connecting to the database and using select to get list of strings (Countries). Take these list and sort it using a Collator with Chinese Locale (I tried olso the new Locale("zh","CN")).
Please assist!
Here is my code:
import java.text.*;
import java.util.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import java.sql.ResultSet;

public class Sort {
public static void main(String s[]) {
Vector list = connectToDB();

Collator collate = Collator.getInstance(Locale.SIMPLIFIED_CHINESE);
Collections.sort(list, collate);
StringBuffer result = new StringBuffer();
for (int i = 0; i < list.size(); i++) {
result.append(" "); //$NON-NLS-1$
System.out.println("\nPrint After Sorting:"); // Print col 1


private static Vector connectToDB() {
Vector list = new Vector();
try {

Connection con = null;
con = DriverManager.getConnection(
"jdbc racle:thin:@ORACLE-TESTVM:1521 ratest", "GROUPAMA_28_08", "GROUPAMA_28_08");
Statement s = con.createStatement();

ResultSet rset = s.executeQuery("select RESOURCE_VALUE from t_resources where resource_lang = 'zh' and resource_code in \n" +
"(select distinct dsc_id from T_COUNTRY)");
System.out.println("Print Before Sorting:"); // Print col 1
while ( {
System.out.println(rset.getString(1)); // Print col 1

System.out.println("\n*********************\nEnd of Print Before Sorting:"); // Print col 1
} catch (Exception e) {
return list;
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic