package org.simantics.utils.datastructures; import java.util.Comparator; /** * Compares strings using their toString() value. * * @author toni.kalajainen@semantum.fi */ public class ToStringComparator implements Comparator { @Override public int compare(Object arg0, Object arg1) { String s1 = arg0.toString(); String s2 = arg1.toString(); return s1.compareTo(s2); } public static class ByLength implements Comparator { @Override public int compare(Object arg0, Object arg1) { String s1 = arg0.toString(); String s2 = arg1.toString(); int l1 = s1.length(); int l2 = s2.length(); return l1 - l2; } } }