/**
* 排序方法
* @param list
* @return
*/
public List<Map<String, Object>> compareBytime(List<Map<String, Object>> list){
Collections.sort(list, new Comparator<Map<String, Object>>(){
public int compare(Map<String, Object> o1, Map<String, Object> o2) {
String name1 =(String)o1.get("time");//name1是从你list里面拿出来的一个
String name2= (String)o2.get("time"); //name1是从你list里面拿出来的第二个name
return name1.compareTo(name2);
}
});
return list;
}
/**
* 去重方法
* @param list
* @return
*/
public List<Map<String, Object>> outRepeat(List<Map<String, Object>> oldList){
List<Map<String, Object>> newList = new ArrayList<Map<String, Object>>();
for(Map oldmap : oldList){
String oldTime = oldmap.get("time").toString();
int t =0;
for(Map newmap : newList){
String newTime = newmap.get("time").toString();
if(newTime.equals(oldTime)){
break;
}
t++;
}
if(t == newList.size()){
newList.add(oldmap);
}
}
return newList;
}
* 排序方法
* @param list
* @return
*/
public List<Map<String, Object>> compareBytime(List<Map<String, Object>> list){
Collections.sort(list, new Comparator<Map<String, Object>>(){
public int compare(Map<String, Object> o1, Map<String, Object> o2) {
String name1 =(String)o1.get("time");//name1是从你list里面拿出来的一个
String name2= (String)o2.get("time"); //name1是从你list里面拿出来的第二个name
return name1.compareTo(name2);
}
});
return list;
}
/**
* 去重方法
* @param list
* @return
*/
public List<Map<String, Object>> outRepeat(List<Map<String, Object>> oldList){
List<Map<String, Object>> newList = new ArrayList<Map<String, Object>>();
for(Map oldmap : oldList){
String oldTime = oldmap.get("time").toString();
int t =0;
for(Map newmap : newList){
String newTime = newmap.get("time").toString();
if(newTime.equals(oldTime)){
break;
}
t++;
}
if(t == newList.size()){
newList.add(oldmap);
}
}
return newList;
}