Ok, I think I now made sense of it all and figured out the actual problem:
Kirby 3 has changed its internal workings in a way that
- if you use the
toStructure()method, you receive aStructureobject, that is in itself a collection of so calledstructureObjectobjects - if you use the
toGroup()method you receive aCollectionobject, which is a collection ofStructure()objects which are a collection ofStructureObjectobjects
That all makes sense so far, I guess, they just redefined the type of objects.
The problem now is, that the Structure object apparently was changed in a way that I cannot write custom fields to it anymore (as it is just supposed to only hold StructureObject objects). And the problem with this is, that this makes it impossible for me to easily sort the groups (or Structure objects actually) within a Collection with the sortBy() method.
In Kirby 2 I could just assign a custom field to any Structure object within a collection and then sort the Structure objects in this collection by this custom field.
I think I will open an issue about this on GitHub. If somebody has any idea how to solve this another way, I am all ears.