/** * Sorts our values by {@code comparator} (and continually applies the comparator as new values * are added/removed/set). */ public void setComparator(Comparator<E> comparator) { this.persistentComparator = comparator; List<E> copy = copyLastValue(getDirect()); if (copy != null && !copy.equals(getDirect())) { set(copy); } }