根据复杂类的某个属性(字符串)排序

这里Expense是个自定义的类
List list=this.getExpenseService().getListByHQL("Expense",0,10,sql);
//根据Expense中类别(type属性)对List<Expense>排序
Collections.sort(list, new Comparator<Expense>(){

	public int compare(Expense e1, Expense e2) {
	// TODO Auto-generated method stub
	      return e2.getType().compareTo(e1.getType());//这里是type
	}
				
});



java集合容器类接口的总结
http://lehsyh.iteye.com/blog/588395

你可能感兴趣的:(java,sql,Blog)