摘要:在很多中文书籍的作者页中,有很多作者的话,很多时候,是按作者姓名的笔画顺序排序的。Microsoft的Excel和Sql Server实现了按笔画排序的功能。那按笔画顺序排序,在Java中究竟怎样实现呢? 作者:Jeff 发表于:2007-12-20 20:39 最后更新于: 2007年12月21日 12:17 合并了已经将《中文排序--笔画》和《中文排序--汉语拼音》修改并合并《中文排序》中。这里只保留最后的代码。实现的原理和方法请见中文排序 /** import java.util.Comparator; public class StrokeComparator implements Comparator<String> { public int compare(String o1, String o2) { Chinese chinese = new Chinese(); for (int i = 0; i < o1.length() && i < o2.length(); i++) { int stroke1 = chinese.stroke(codePoint1); if (stroke1 < 0 || stroke2 < 0) { if (stroke1 != stroke2) { return o1.length() - o2.length(); |
|
来自: shaobin0604@1... > 《Java》