package ipipan.poliqarp.stat;

import java.util.Comparator;
import java.util.Map;

public class AttrValueComparator implements Comparator<String> {
   Map<String, Integer> valToInt;

   public AttrValueComparator(Map<String, Integer> values) {
      valToInt = values;
   }

   public int compare(String s1, String s2) {
      Integer v1, v2;
      v1 = valToInt.get(s1);
      v2 = valToInt.get(s2);
      if (v1 == null && v2 == null) return s1.compareTo(s2);
      if (v1 == null) return 1;
      if (v2 == null) return -1;
      return v1.compareTo(v2);
   }
}
