这是我一个Map里面的部分数据,COUNTS=1 的都要显示在页面,0的侧不用。
现在要求所有‘审核不通过‘的显示置前。 请问我应该怎么排序啊,
有一点就是无论怎么排序,所有数据都必须在一个集合里面,这样不影响前端取值。
{DESCRIPT=客户待接收, URL=CustomerReceivingAction!toCustomerReceivingList.action?status=1, COUNTS=1}
{DESCRIPT=意向跟进待制定计划, URL=intention/IntentionPlanAction!toIntentionPlanEditList.action?IS_TASK=0, COUNTS=0}
{DESCRIPT=关系维护待回访, URL=relationmaintenance/IntentionVisitAction!toVisitList.action, COUNTS=2}
{DESCRIPT=客户审核不通过, URL=CustomerCollecAction!toCustomerCollecAddList.action?status=1, COUNTS=1}
{DESCRIPT=意向跟进计划审核未通过,URL=IntentionPlanAction!toIntentionPlanEditList.action?status=1, COUNTS=3}
{DESCRIPT=成交促进回访审核未通过, URL=promote/ItentionFollowAction!toIntentionFollowList.action, COUNTS=1}
哪位大哥帮帮忙啊,最好有代码。javaMap List排序集合
现在要求所有‘审核不通过‘的显示置前。 请问我应该怎么排序啊,
有一点就是无论怎么排序,所有数据都必须在一个集合里面,这样不影响前端取值。
{DESCRIPT=客户待接收, URL=CustomerReceivingAction!toCustomerReceivingList.action?status=1, COUNTS=1}
{DESCRIPT=意向跟进待制定计划, URL=intention/IntentionPlanAction!toIntentionPlanEditList.action?IS_TASK=0, COUNTS=0}
{DESCRIPT=关系维护待回访, URL=relationmaintenance/IntentionVisitAction!toVisitList.action, COUNTS=2}
{DESCRIPT=客户审核不通过, URL=CustomerCollecAction!toCustomerCollecAddList.action?status=1, COUNTS=1}
{DESCRIPT=意向跟进计划审核未通过,URL=IntentionPlanAction!toIntentionPlanEditList.action?status=1, COUNTS=3}
{DESCRIPT=成交促进回访审核未通过, URL=promote/ItentionFollowAction!toIntentionFollowList.action, COUNTS=1}
哪位大哥帮帮忙啊,最好有代码。javaMap List排序集合
不过借助apache common中的org.apache.commons.collections.map
Class ListOrderedMap倒是可以有序显示,这个map的key你想怎么表示?
先放进去就会排前面吗
我是想要所有’审核未通过‘ 并且 COUNTS=1 排序放在前面显示.判断不好写啊,其他数据不能过滤,也是要放进去,只是顺序变了、
map key是有序的而且不能重复,你先读那一个就放那一个,这个顺序由你定的
class ComparatorOrd implements Comparator<Map<String,String>>{
public int compare(Map<String, String> o1, Map<String, String> o2) {
int flag = 0;
int ord1 = Integer.parseInt(o1.get("ord"));
int ord2 = Integer.parseInt(o2.get("ord"));
if(ord1 > ord2){
flag = 1;
}else if( ord1 < ord2){
flag = -1;
}
return flag;
}
}Collections.sort(bcaUserList, new ComparatorOrd());
for (int i = 0; i < lst.size(); i++) { //遍历所有的MAP
HashMap<String, String> firMap = lst.get(i); //得到当前遍历到的MAP对象
if ("成交促进回访审核未通过".equals(firMap.get("DESCRIPT"))) { //如果前面的是审核不通过的,位置就不调换它的
continue;
}
for (int j = i+1; j < lst.size(); j++) { //如果不是审核不通过的,我们就到后面的MAP中去找,找到之后,调换位置
System.out.println(j);
HashMap<String,String> lastMap = lst.get(j);
System.out.println(lastMap.get("DESCRIPT"));
if ("成交促进回访审核未通过".equals(lastMap.get("DESCRIPT"))) { //如果这个是审核不通过的,位置就调换它的
HashMap<String, String> TempMap = null; //用来给两个MAP调换位置用
TempMap = firMap;
lst.set(i, lastMap);
lst.set(j, TempMap);
System.out.println(lst);
break;
}
}
}
return lst;
}
的排前LIST最前面了,你要把其它的排前面就自已在IF里面改条件!