对集合排序

页面引用:
<h:commandButton value="ASC" styleClass="clsFont" action="#{timeVoucheringBean.sortAsc}"/>
<h:commandButton value="DESC" styleClass="clsFont" action="#{timeVoucheringBean.sortDesc}"/>

Backbean 方法

public void sortAsc() {
   this.logger.info("Asc");
   Collections.sort(secProjNoAndSecProjDescList, new  
      Comparator<ProjectDetails>(){   
           public int compare(ProjectDetails arg0, ProjectDetails arg1) {   
               return arg0.getProjectNumber().compareTo(arg1.getProjectNumber());   
            }   
        });   
}

public void sortDesc() {
this.logger.info("Desc");
Collections.sort(secProjNoAndSecProjDescList, new Comparator<ProjectDetails>(){   
           public int compare(ProjectDetails arg0, ProjectDetails arg1) {   
               return arg1.getProjectNumber().compareTo(arg0.getProjectNumber());   
            }   
        });   
}

你可能感兴趣的:(排序)