public class ToStringComparator<T> extends Object implements Comparator<T>, Serializable
Comparator
interface which uses
the result of the toString
method to compare the objects.
Ie. by using this comparator objects are sorted according to the
toString()
values.
Note: this comparator may impose orderings that are inconsistent with equals.
Modifier and Type | Field and Description |
---|---|
private boolean |
descending |
private static long |
serialVersionUID |
Constructor and Description |
---|
ToStringComparator(boolean descending)
Create a new comparator.
|
private static final long serialVersionUID
private final boolean descending
public ToStringComparator(boolean descending)
descending
- TRUE to sort objects in descending order (z--a),
FALSE to sort the objects in ascending order (a--z)public int compare(T o1, T o2)
compare
in interface Comparator<T>