### Question:
Ordering implements Comparator<Object>, Serializable, XMLSerializable { @Override public int compare(Object o1, Object o2) { Expression exp = getSortSpec(); Object value1 = null; Object value2 = null; try { value1 = exp.evaluate(o1); } catch (ExpressionException e) { if (pathExceptionSuppressed && e.getCause() instanceof org.apache.cayenne.reflect.UnresolvablePathException) { } else { throw e; } } try { value2 = exp.evaluate(o2); } catch (ExpressionException e) { if (pathExceptionSuppressed && e.getCause() instanceof org.apache.cayenne.reflect.UnresolvablePathException) { } else { throw e; } } if (value1 == null && value2 == null) { return 0; } else if (value1 == null) { return nullSortedFirst ? -1 : 1; } else if (value2 == null) { return nullSortedFirst ? 1 : -1; } if (isCaseInsensitive()) { value1 = ConversionUtil.toUpperCase(value1); value2 = ConversionUtil.toUpperCase(value2); } int compareResult = ConversionUtil.toComparable(value1).compareTo(ConversionUtil.toComparable(value2)); return (isAscending()) ? compareResult : -compareResult; } Ordering();  Ordering(String sortPathSpec);  Ordering(String sortPathSpec, SortOrder sortOrder);  Ordering(Expression sortSpec);  Ordering(Expression sortSpec, SortOrder sortOrder); @SuppressWarnings("unchecked") static void orderList(List<?> objects, List<? extends Ordering> orderings); static List<E> orderedList(final Collection<E> objects, List<? extends Ordering> orderings); @Override boolean equals(Object object); @Override int hashCode(); void setSortSpecString(String sortSpecString); void setNullSortedFirst(boolean nullSortedFirst); boolean isNullSortedFirst(); void setPathExceptionSupressed(boolean pathExceptionSuppressed); boolean isPathExceptionSuppressed(); String getSortSpecString(); void setSortOrder(SortOrder order); boolean isAscending(); boolean isDescending(); void setAscending(); void setDescending(); boolean isCaseInsensitive(); boolean isCaseSensitive(); void setCaseInsensitive(); void setCaseSensitive(); Expression getSortSpec(); void setSortSpec(Expression sortSpec); void orderList(List<?> objects); List<E> orderedList(Collection<E> objects); @Override int compare(Object o1, Object o2); @Override void encodeAsXML(XMLEncoder encoder, ConfigurationNodeVisitor delegate); @Override String toString(); SortOrder getSortOrder(); Orderings then(Ordering nextOrdering); Orderings then(Orderings nextOrderings); Orderings then(List<Ordering> nextOrderings);  }### Answer:
@Test public void testCompare3() { Painting p1 = new Painting(); p1.setEstimatedPrice(new BigDecimal(1000.00)); Painting p2 = new Painting(); p2.setEstimatedPrice(new BigDecimal(2000.00)); Painting p3 = new Painting(); p3.setEstimatedPrice(new BigDecimal(2000.00)); Ordering ordering = new Ordering("estimatedPrice", SortOrder.ASCENDING); assertTrue(ordering.compare(p1, p2) < 0); assertTrue(ordering.compare(p2, p1) > 0); assertTrue(ordering.compare(p2, p3) == 0); }
@Test public void testCompare4() { TstBean t1 = new TstBean(1000); TstBean t2 = new TstBean(2000); TstBean t3 = new TstBean(2000); Ordering ordering = new Ordering("integer", SortOrder.ASCENDING); assertTrue(ordering.compare(t1, t2) < 0); assertTrue(ordering.compare(t2, t1) > 0); assertTrue(ordering.compare(t2, t3) == 0); }