Collections.sort()排序使用方法

来源:互联网 发布:高德地图数据购买 编辑:程序博客网 时间:2024/05/17 06:30

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

  List reList 
= new ArrayList();
     
  Collections.sort(reList, 
new Comparator() {

   
// Parameters:
   
// o1 - the first object to be compared.
   
// o2 - the second object to be compared.
   
// Returns:
   
// a negative integer, zero, or a positive integer as the first
   
// argument is less than, equal to, or greater than the second.
   
// Throws:
   
// ClassCastException - if the arguments' types prevent them from
   
// being compared by this Comparator.
   public int compare(Object o1, Object o2) {
    
// TODO Auto-generated method stub
    return 0;
   }

  });