How to add sortBy (use sort order of field in other blueprint) to groupBy?

I am showing registrations to tennis tournaments and want to group them by players Groups.

Tried this example https://getkirby.com/docs/reference/objects/pages/group-by#example and it’s working fine. Only there are two things, that I can’t figure out:

  1. groups are printed in lowercase, although they are stored normally in blueprints.

  2. How can I sort by Groups, where group order should be the same, as it is in “Event” page, from which Group name goes to registration:

select

If they are stored in lowercase then they will be printed in lowercase.

If your groups are sorted alphabetically, you can just add a sortBy(), if it is some custom order, you will have to map a value to each group to sort by.

In blueprint values are with capital letter, for example: Group: Pirma grupÄ—, but still group value is printed in all lowercase.

To sort alphabetically with sortBy() - that’s working well, but the question is how to have the same order, as this field option values have in blueprint (there is not certain sort, like alphabetical).

I was asking what is stored in your content file, not in the blueprint.

Well, then you have to eitherread that order from the blueprint or create an array of values in the same order and assign a sort number to them, then sort by that array.

Basically, you would first use map() to assign a sorting order to the grouped collection, then use this assigned sort value to sort by.

Or you sort your registrations first by that grouping value, then group, like here:

Sorry, I meant to say, that it’s stored in content file (registration.txt), so yes, it’s with capital letters there: Group: Pirma grupė

Thank you for information about ordering, will check it out.

Hm, in any case you can use ucfirst() to make the first letter an uppercase letter again.