I have an entity A that has an ordered to-many relationship to another entity B.
I'd like to sort a fetchrequest for A by a property (name) of the first (if available) B.
For example, I have
- A1 that is related to B.name = "Alice" and B.name = "Bob" and
- A2 that is related to B.name = "Eve"
Now I want to build a SortDescriptor that orders them by the name of the first B, i.e. A1, A2
Intuitively, I'd try to use
SortDescriptor(\A.relationship?.firstObject?.name)
but that doesn't compile (Failed to produce diagnostic for expression;).
Is this simply not possible or am I missing something?