package com.tool.com.lib; import java.text.CollationKey; import java.text.Collator; import java.util.Comparator; import com.tool.com.object.ObjectWebsite; public class SortBrowserDataByModel implements Comparator { @Override public int compare(Object o1, Object o2) { ObjectWebsite stu1 = (ObjectWebsite) o1; ObjectWebsite stu2 = (ObjectWebsite) o2; // --字符串比较 String v1 = stu1.getFunctionMode().toString(); String v2 = stu2.getFunctionMode().toString(); Collator myCollator = Collator.getInstance(); CollationKey[] keys = new CollationKey[5]; keys[0] = myCollator.getCollationKey(v1); keys[1] = myCollator.getCollationKey(v2); String v11 = stu1.getName().toString(); String v21 = stu2.getName().toString(); Collator myCollator1 = Collator.getInstance(); CollationKey[] keys1 = new CollationKey[5]; keys1[0] = myCollator1.getCollationKey(v11); keys1[1] = myCollator1.getCollationKey(v21); int temp1 = keys[0].compareTo(keys[1]); int temp2 = keys1[0].compareTo(keys1[1]); if(temp1==0) { return temp2; } return (keys[0].compareTo(keys[1])); //return ((keys[0].compareTo(keys[1]))+(keys1[0].compareTo(keys1[1]))); } }