You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
529 B
Java
27 lines
529 B
Java
package com.inswave.template.service;
|
|
|
|
import java.util.Collections;
|
|
import java.util.Comparator;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
public class Test {
|
|
public List sortByValue(final Map map, List list) {
|
|
list.addAll(map.keySet());
|
|
|
|
Collections.sort(list, new Comparator() {
|
|
|
|
public int compare(Object o1, Object o2) {
|
|
Object v1 = map.get(o1);
|
|
Object v2 = map.get(o2);
|
|
|
|
return ((Comparable) v1).compareTo(v2);
|
|
}
|
|
|
|
});
|
|
Collections.reverse(list); // 주석시 오름차순
|
|
return list;
|
|
|
|
}
|
|
}
|