! Collection.sort(). (, TreeSet). , , Set to a List.
Person Comparable, Collections.sort(), , . - :
public class Person implements Comparable<Person> {
...
@Override
public int compareTo(Person p) {
return this.name.compareTo(p.name);
}
}
TreeSet, . , , Collections.sort( l) .