java list 数组对某个属性进行排序

//在实体类中须要实现Comparable<实体类>
在实体类中实现方法
public int compareTo(ShopProduct o) {
        // TODO Auto-generated method stub
        return Integer.valueOf(o.getSales()) - Integer.valueOf(this.sales);
    }
在业务逻辑中的使用方法为:
 Collections.sort(list数组);
复制代码
相关文章
相关标签/搜索