import java.util.Comparator;
import java.util.Objects;

/** A comparator that orders values based on the lexicographic ordering of their toString(). */
public class ToStringComparator implements Comparator<Object> {
  /** The unique instance (this class is a singleton). */
  public static ToStringComparator instance = new ToStringComparator();

  /** Creates a ToStringComparator. */
  private ToStringComparator() {}

  @Override
  public int compare(Object o1, Object o2) {
    return Objects.toString(o1).compareTo(Objects.toString(o2));
  }
}

@@ -1,24 +1,80 @@
+package org.plumelib.util;%0A%0Aimport java.util.ArrayList;%0A
 import java.util.Compara
@@ -78,16 +78,39 @@
 arator;%0A
+import java.util.List;%0A
 import j
@@ -618,11 +618,418 @@
 2));%0A  %7D
+%0A%0A  /**%0A   * Returns a copy of the input, sorted according to the elements' %7B@code toString()%7D.%0A   *%0A   * @param in a set of elements%0A   * @return the elements, sorted according to %7B@code toString()%7D%0A   */%0A  public static %3CT%3E List%3CT%3E sorted(Iterable%3CT%3E in) %7B%0A    List%3CT%3E result = new ArrayList%3CT%3E();%0A    for (T object : in) %7B%0A      result.add(object);%0A    %7D%0A    result.sort(instance);%0A    return result;%0A  %7D
 %0A%7D%0A

Add package and `sorted` method to ToStringComparator