首先准备一个要排序的list:tempList
然后写一个类:tempComparator,该类实现Comparator ,在实现方法int compare(Object o1,Object o2){}中写出你要的规则(任何你想要的规则),返回值为1或0,具体情况根据你 的需要!
最后:
Collections.sort(tempList,tempComparator);
此时tempList将是一个你写的规则排好序的集合!
然后写一个类:tempComparator,该类实现Comparator ,在实现方法int compare(Object o1,Object o2){}中写出你要的规则(任何你想要的规则),返回值为1或0,具体情况根据你 的需要!
最后:
Collections.sort(tempList,tempComparator);
此时tempList将是一个你写的规则排好序的集合!