### Question:
GroupingList extends TransformedList<E, List<E>> { public void setComparator(Comparator<? super E> comparator) { if (comparator == null) comparator = (Comparator) GlazedLists.comparableComparator(); ((SortedList<E>) source).setComparator(comparator); } GroupingList(EventList<E> source);  GroupingList(EventList<E> source, Comparator<? super E> comparator); private  GroupingList(SortedList<E> source, Comparator<? super E> comparator, Void dummyParameter); static GroupingList<E> create(EventList<E> source); int indexOfGroup(E groupElement); void setComparator(Comparator<? super E> comparator); @Override void listChanged(ListEvent<E> listChanges); @Override List<E> get(int index); @Override List<E> remove(int index); @Override List<E> set(int index, List<E> value); @Override void add(int index, List<E> value); @Override int size(); @Override void dispose();  }### Answer:
@Test public void testSetComparator() { final EventList<String> source = new BasicEventList<>(); final GroupingList<String> groupingList = new GroupingList<>(source, GlazedListsTests.getFirstLetterComparator()); ListConsistencyListener<List<String>> listConsistencyListener = ListConsistencyListener.install(groupingList); listConsistencyListener.setPreviousElementTracked(false); source.add("Black"); source.add("Blind"); source.add("Bling"); assertEquals(1, groupingList.size()); assertEquals(Arrays.asList("Black", "Blind", "Bling"), groupingList.get(0)); groupingList.setComparator(GlazedListsTests.getLastLetterComparator()); assertEquals(3, groupingList.size()); assertEquals(Arrays.asList("Blind"), groupingList.get(0)); assertEquals(Arrays.asList("Bling"), groupingList.get(1)); assertEquals(Arrays.asList("Black"), groupingList.get(2)); groupingList.setComparator(GlazedListsTests.getFirstLetterComparator()); assertEquals(1, groupingList.size()); assertEquals(Arrays.asList("Black", "Blind", "Bling"), groupingList.get(0)); groupingList.setComparator(null); assertEquals(3, groupingList.size()); assertEquals(Arrays.asList("Black"), groupingList.get(0)); assertEquals(Arrays.asList("Blind"), groupingList.get(1)); assertEquals(Arrays.asList("Bling"), groupingList.get(2)); }