Client-side Sorting

The sortedBy() element specifies that the collection be ordered using the specified comparator, rather than the natural ordering of the entity (as would usually be the case).

For example:

import lombok.Getter;
import lombok.Setter;

public class ToDoItem implements Comparable<ToDoItem> {         (1)

    public static class DescriptionComparator                   (2)
                            implements Comparator<ToDoItem> {
        @Override
        public int compare(ToDoItem o1, ToDoItem o2) {
            return Comparator.comparing(ToDoItem::getDescription)
                             .compare(o1, o2);
        }
    }

    @CollectionLayout(sortedBy=DependenciesComparator.class)    (3)
    @Getter @Setter
    private SortedSet<ToDoItem> dependencies = ...

}
1 the class has a natural ordering (implementation not shown)
2 declaration of an alternative comparator class, using the object’s description property
3 ordering of the collection defined as being by this comparator

When the dependencies collection is rendered, the elements are sorted by the description property first.