【发布时间】:2011-10-20 17:37:17
【问题描述】:
我有一个 Hashmap 的 Vector,而 HashMap 包含不同的数据类型:
Vector<HashMap<String, Object>> theVector= new Vector<HashMap<String, Object>>();
theResults 包含这个 HashMap:
HashMap<String, Object> theHashMap= new HashMap<String, Object>();
theHashMap 有这些数据: (假设这是一个 for 循环)
//1st set
theHashMap.put("BLDG_ID", 111); //int
theHashMap.put("EMP_NAME", "AAA"); //String
theHashMap.put("FLAG", true); //boolean
theVector.add(theHashMap);
//2nd set
theHashMap.put("BLDG_ID", 222); //int
theHashMap.put("EMP_NAME", "BBB"); //String
theHashMap.put("FLAG", false); //boolean
theVector.add(theHashMap);
//2nd set<br>
theHashMap.put("BLDG_ID", 111); //int
theHashMap.put("EMP_NAME", "CCC"); //String
theHashMap.put("FLAG", false); //boolean
theVector.add(theHashMap);
我想根据 BLDG_ID 对 HashMap 向量的内容进行排序,以便在显示数据时看起来像
BLDG_ID || EMP_NAME
111 || AAA
111 || CCC
222 || BBB
我该怎么做?
【问题讨论】:
-
我的 >和 <已被剥离这里再次声明 theVector'' Vector <HashMapvString, Object>> theVector= new Vector
>(); -
请学习如何使用 Markdown:stackoverflow.com/editing-help
-
啊。我的 已被剥离,这里再次声明 theVector'' Vector
> theVector= new Vector >(); HashMap theHashMap= new HashMap ();
标签: java sorting vector hashmap