Kirby collection sorting by key question

Hi,

What would be the best way to sort Kirby 4 Collection that uses dates as keys for arrays which can be added in random order, example:

So i would like to sort that collection according to its string data value. Thoughts?

Also those keys contains arrays themselves.

Why does the date have to be the key and cannot be a value inside each entry’s array?

What you’re trying to do is a bit unclear to me. What’s the shape of the data you have initially, and what’s the shape of the data you’re trying to create?

You have a collection with a data array with keys which already look sorted. Are you trying to sort the keys in that array in a different way from what you’re showing?

It is not sorted per the screenshot.

If anybody tried to do anything that looked like that you basically have 2 choices to solve it:

  • Move date to each entry array per distantnative answer,
  • Use instead Kirby\Cms\Structure which allows you to use sort() method which is going to work on keys just fine

Cheers.