Java中對List進(jìn)行字典序排序
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
private List<Type> list = new ArrayList<>();
Collections.sort(list, new Comparator<Type>() {
@Override
public int compare(Type o1, Type o2) {
return o1.compareTo(o2);
}
});
//倒序排列
Collections.reverse(list);