class SnomedCodeComparator implements Comparator<SnomedConcept> {

    public int compare(final SnomedConcept o1, final SnomedConcept o2) {
        if (o1 == o2) return 0;
        if (o1 != null) {
            if (o2 == null) return 1;
                // need to use BigInteger to compare SNOMED codes since some are fantastically long
            else return new BigInteger(o1.snomedId)
                    .compareTo(new BigInteger(o2.snomedId));
        }
        return -1;
    }

}