org.aksw.commons.collections.ValueComparator Maven / Gradle / Ivy
package org.aksw.commons.collections;
import java.util.Comparator;
import java.util.Map;
/**Compares elements based on the order of their values in a given map.
* Based on
* Stack Overflow: How to sort a Map on the values in Java? .
* @author Konrad Höffner */
public class ValueComparator> implements Comparator
{
Map map;
public ValueComparator(Map map) {setMap(map);}
public void setMap(Map map) {this.map = map;}
@Override
public int compare(S s, S t) {return map.get(s). compareTo(map.get(t));}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy