java按对象属性排序

List<GoodsPrice> prices = goods.getPrices();
// 将价格排序
Collections.sort(prices, new Comparator<GoodsPrice>() {
	public int compare(GoodsPrice o1, GoodsPrice o2) {
		return o2.getPrice().compareTo(o1.getPrice());
	}
});

你可能感兴趣的:(java)