### Question:
ValueComparator implements Comparator<Object> { private int compareDocuments(Document document1, Document document2) { List<String> keys1 = new ArrayList<>(document1.keySet()); List<String> keys2 = new ArrayList<>(document2.keySet()); for (int i = 0; i < Math.max(keys1.size(), keys2.size()); i++) { String key1 = i >= keys1.size() ? null : keys1.get(i); String key2 = i >= keys2.size() ? null : keys2.get(i); Object value1 = document1.getOrMissing(key1); Object value2 = document2.getOrMissing(key2); int typeComparison = compareTypes(value1, value2); if (typeComparison != 0) { return typeComparison; } int keyComparison = compareAsc(key1, key2); if (keyComparison != 0) { return keyComparison; } int valueComparison = compareAsc(value1, value2); if (valueComparison != 0) { return valueComparison; } } return 0; } private  ValueComparator(boolean ascending); private  ValueComparator(boolean ascending, boolean handleLists, boolean useDefaultComparatorForUuids); static ValueComparator asc(); static ValueComparator ascWithoutListHandling(); static ValueComparator desc(); ValueComparator withDefaultComparatorForUuids(); @Override ValueComparator reversed(); @Override int compare(Object o1, Object o2);  }### Answer:
@Test void testCompareDocuments() throws Exception { assertComparesTheSame(json("a: 1"), json("a: 1.0")); assertComparesTheSame(json("a: 0"), json("a: -0.0")); assertComparesTheSame(json("a: {b: 1}"), json("a: {b: 1.0}")); assertDocumentComparison("a: -1", "a: 0"); assertDocumentComparison("a: 1", "a: 1, b: 1"); assertDocumentComparison("a: {b: 1}", "a: {c: 2}"); assertDocumentComparison("a: {b: 1}", "a: {c: 0}"); assertDocumentComparison("a: {b: -1.0}", "a: {b: 1}"); assertDocumentComparison("a: {b: 1}", "a: {b: 1, c: 1}"); assertDocumentComparison("a: {b: 1}", "a: {b: 1, c: null}"); assertDocumentComparison("a: {b: 1, c: 0}", "a: {b: {c: 1}}"); assertDocumentComparison("a: {b: null, c: 0}", "a: {b: {c: 0}}"); assertDocumentComparison("a: {c: 0}", "a: {b: 'abc'}"); assertDocumentComparison("a: {c: 0}", "a: {b: {c: 0}}"); }