### Question:
Concepts extends ArrayList<ConceptWithObservations> { public void sortByDate() { Collections.sort(this, new Comparator<ConceptWithObservations>() { @Override public int compare(ConceptWithObservations lhs, ConceptWithObservations rhs) { return -(lhs.getObservations().get(0).getObservationDatetime() .compareTo(rhs.getObservations().get(0).getObservationDatetime())); } }); } Concepts();  Concepts(Observation... observations);  Concepts(List<Observation> observationsByPatient); void sortByDate();  }### Answer:
@Test public void shouldSortTheConceptsByDate() { final Observation observation1 = createObservation(createConcept("c1"), "01", new Date(1)); final Observation observation2 = createObservation(createConcept("c2"), "02", new Date(3)); final Observation observation3 = createObservation(createConcept("c1"), "03", new Date(2)); final Concepts concepts = new Concepts(observation1, observation2, observation3); concepts.sortByDate(); final Concepts expectedOrderedConcept = new Concepts() {{ add(conceptWithObservations(observation2)); add(conceptWithObservations(observation3, observation1)); }}; assertThat(concepts, is(expectedOrderedConcept)); }