思路:将每个汉字都转换为一个汉字对象,利用汉字对象拥有的拼音属性排序.
import java.util.*;public class gb implements Comparable{
    private String gb;        //汉字
    private String gbKey;     //对应的拼音
    gb(String gb1,String gbKey1) {
         gb=gb1;
         gbKey=gbKey1;
    }
    String getGbKey(){
         return gbKey;
    }
    public int compareTo(Object o){
         return gbKey.compareTo((gb)o.getGbKey())
    }    public void main(String[] args){
         gb[] gbs=new gb[n]
         ...........        //将汉字对象存入容器中
         Arrays.sort(gbs)   //排序
    }
}如果只排序少许几个汉字还可以.

解决方案 »

  1.   

    http://expert.csdn.net/Expert/topic/2127/2127208.xml?temp=.891369
      

  2.   

    java中的汉字排序问题,归根结蒂是比较的问题,至于比较可以参考下面的代码噢!public class gbkStringCompareTools {
      private static String _FromEncode_ = "GBK";
      private static String _ToEncode_ = "GBK";
      protected  gbkStringCompareTools() {
      }  public static int compare(String str1,String str2){
        int result =0;
        String m_s1 = null,m_s2 = null;
        try {
          m_s1 = new String(str1.getBytes(_FromEncode_),_ToEncode_);
          m_s2 = new String(str2.getBytes(_FromEncode_),_ToEncode_);
        } catch(Exception e){
          return str1.compareTo(str2);
        }
        result = chineseCompareTo(m_s1,m_s2);
        return result;
      }  public  static int getCharCode(String s){
        if (s == null && s.equals(""))
          return -1;
        byte[] b = s.getBytes();
        int value = 0;
        for (int i = 0; i < b.length && i <= 2; i++){
          value = value*100 + b[i]; //*100左移
        }
        return value;
      }  public static int chineseCompareTo(String s1, String s2) {
        int len1 = s1.length();
        int len2 = s2.length();
        int n = Math.min(len1, len2);
        for (int i = 0; i < n; i++) {
          int s1_code = getCharCode(s1.charAt(i) + "");
          int s2_code = getCharCode(s2.charAt(i) + "");
          if (s1_code*s2_code<0)
            return Math.min(s1_code,s2_code);
          if (s1_code != s2_code)
            return s1_code - s2_code;
        }
        return len1 - len2;
      }
    }
      

  3.   

    hoho,上面的代码能够解决一级汉字的拼音排序问题!!通常的应用场合,完全够用喽!!!这可是偶老人家郁闷了一天之后才搞定的!
      

  4.   

    zhang21cnboy(事了抚衣去,不留身与名) 有一点意义。意义不大。
      

  5.   

    lynx1111(任我行) ( )的也毫无意义。
      

  6.   

    feiyuegaoshan(飞跃) ,看你两个星星,听牛比的,你给咱搞一个有意义的,如何呢???
      

  7.   

    如果是拼音排序的话,jdk提供了对应的方法 ^_^
      

  8.   

    Collator c = Collator.getInstance( Locale.CHINA );
    int revl = c.compare( "中", "华" );
    System.out.println( "Res = " + revl );
    //"中"的拼音排序在"华"之后啊,所以是小于,所以这里将输出-1这里实现了中文按照拼音比较大小
    那么对于一列中文的排序只需要将这些中文放入一个List,然后调用 Collections.sort(List, Comparator) 这个方法既可
      

  9.   

    to: zhang21cnboy(事了抚衣去,不留身与名) ( ) 
    我很普通。不如你说的NB。
      

  10.   

    danceflash(Wine) 的思路有点对。但代码完全不对。
    代码是按unicode编码排序的。
      

  11.   

    import java.io.UnsupportedEncodingException; 
    import java.util.Arrays; 
    import java.util.Comparator;
    import java.util.*;
    import java.util.Collections;public class sort { 
        public static void main( String[] args ) throws UnsupportedEncodingException { 
            String[] s = {"孙", "孟", "宋", "尹", "廖", "张", "张", "张", "徐", "昆", "曹", "曾"}; 
            String[] c = new String[s.length]; 
            for ( int i = 0; i < s.length; i++ ) { 
                c[i] = new String( s[i].getBytes("gbk"), "iso-8859-1" ); 
            } 
            /*用数组排序
            Arrays.sort( c, new Comparator() { 
                public int compare( Object o1, Object o2 ) { 
                    return ( ( String ) o1 ).compareTo( ( String ) o2 ); 
                } 
            } 
            );
            */
            //Arrays.sort( c);        //用集合排序
            List list = new ArrayList();
            for (int i = 0; i < c.length; i++) {
              list.add(c[i]);
            }
            Collections.sort(list);
            for (int i = 0; i < c.length; i++) {
              c[i] = (String)list.get(i);
            }
            for ( int i = 0; i < c.length; i++ ) { 
                String cc = c[i]; 
                System.out.println( new String( cc.getBytes( "iso-8859-1" ), "gbk" ) ); 
            } 
        }