### Question:
DocumentComparator implements Comparator<Document> { @Override public int compare(Document document1, Document document2) { for (String sortKey : orderBy.keySet()) { Object value1 = Utils.getSubdocumentValueCollectionAware(document1, sortKey); Object value2 = Utils.getSubdocumentValueCollectionAware(document2, sortKey); final ValueComparator comparator; if (((Number) orderBy.get(sortKey)).intValue() > 0) { comparator = ValueComparator.asc(); } else { comparator = ValueComparator.desc(); } int cmp = comparator.compare(value1, value2); if (cmp != 0) { return cmp; } } return 0; } DocumentComparator(Document orderBy); @Override int compare(Document document1, Document document2);  }### Answer:
@Test void testCompareCompoundKey() throws Exception { DocumentComparator comparator = new DocumentComparator(json("'a.b': 1, c: -1")); Document a = json("a: {b: 10}"); Document b = json("a: {b: 15}"); Document c = json("a: {b: 15, x: 70}"); assertThat(comparator.compare(a, b)).isLessThan(0); assertThat(comparator.compare(b, a)).isGreaterThan(0); assertThat(comparator.compare(b, c)).isZero(); }