/* Sorting Map and return LinkedHashMap, u can send HashMap implemented Object but it should a map like
Map map = new HashMap();
ma p = sortHashMapByValues(map);
*/
public LinkedHashMap sortHashMapByValues(Map passedMap) {
List mapKeys = new ArrayList(passedMap.keySet());
List mapValues = new ArrayList(passedMap.values());
Collections.sort(mapValues);
Collections.sort(mapKeys);
LinkedHashMap sortedMap =
new LinkedHashMap();
Iterator valueIt = mapValues.iterator();
while (valueIt.hasNext()) {
Object val = valueIt.next();
Iterator keyIt = mapKeys.iterator();
while (keyIt.hasNext()) {
Object key = keyIt.next();
String comp1 = passedMap.get(key).toString();
String comp2 = val.toString();
if (comp1.equals(comp2)){
passedMap.remove(key);
mapKeys.remove(key);
sortedMap.put((String)key, val);
break;
}
}
}
return sortedMap;
}
Let us share our views in java. Not only java, we can also share examples and configurations on Spring, Hibernate, javascript, CSS and Sqlserver queries. This blog will help you in giving the complete information and resolving your complete java related problems like the problems in core java, servlets, jsp spring, hibernate. And also the web technologies which includes all css related problems(Web 2.0).and java script and the latest smart jquery java script frame work
Mar 22, 2009
Mar 18, 2009
Sql server pagination query
select* from ( SELECT ROW_NUMBER() OVER (ORDER BY ja.AppName) AS RowNumber, ja.* from Applicant ja )a where a.RowNumber <= uplt and a.RowNumber > lowlt
Subscribe to:
Posts (Atom)