CategoryModel implements Comparable<CategoryModel> { @Override public int compareTo(CategoryModel o) { if (o == this) { return 0; } return name.compareToIgnoreCase(o.name); } CategoryModel(String name); String getName(); @Override int compareTo(CategoryModel o);  }
@Test public void compareTo() { CategoryModel m1 = new CategoryModel("a"); CategoryModel m2 = new CategoryModel("B"); CategoryModel m3 = new CategoryModel("c"); assertOrder(m1, m2, m3); assertEquals(0, m1.compareTo(m1)); assertCompareOrder(m1, m2); assertCompareOrder(m2, m3); }