desc降序

  1. private void descSort(final String order,String dir){ 
  2.         //desc 
  3.         Collections.sort(arrayList, new Comparator<HashMap<String,Object>>(){ 
  4.  
  5.             @Override 
  6.             public int compare(HashMap<String, Object> arg0,HashMap<String, Object> arg1) { 
  7.                 // TODO Auto-generated method stub 
  8.                 return ((String) arg1.get("name")).compareTo((String) arg0.get("name")); 
  9.             } 
  10.         }); 

asc升序

  1. private void ascSort(final String order,String dir){  
  2.        //asc  
  3.        Collections.sort(arrayList, new Comparator<HashMap<String,Object>>(){  
  4.  
  5.            @Override  
  6.            public int compare(HashMap<String, Object> arg0,HashMap<String, Object> arg1) {  
  7.                // TODO Auto-generated method stub  
  8.                return ((String) arg0.get("name")).compareTo((String) arg1.get("name"));  
  9.            }  
  10.        });  
  11. }