項目中經常需要用到比如地區列表按照中文的拼音首字母排序
import java
import java
import java
import java
import mons
import llections
import parators
import parators
public class CompareTipA {
private int id;
private String name;
private String age;
@SuppressWarnings(
public static void main(String []args) {
ArrayList<Object> list = new ArrayList<Object>()
list
list
list
list
list
list
Comparator mycmp = ComparableComparator
mycmp = ComparatorUtils
//允許null
mycmp = ComparatorUtils
ArrayList<Object> sortFields = new ArrayList<Object>()
Comparator<Object> comparator=Collator
sortFields
sortFields
//id逆序 (副)
ComparatorChain multiSort = new ComparatorChain(sortFields)
Collections
for (int i =
System
//輸出 /*
[id=
[id=
[id=
[id=
[id=
[id=
}
}
public CompareTipA(int id
this
this
this
}
public int getId() {
return this
}
public void setId(int id) {
this
}
public String getName() {
return this
}
public void setName(String name) {
this
}
//
public int compareTo(Object o) { //
return pare(this
public String toString() {
return
}
public String getAge() {
return age;
}
public void setAge(String age) {
this
} }
注意
commons
commons
commons
From:http://tw.wingwit.com/Article/program/Java/hx/201311/25790.html