sortBy() behaviour changes from 3.2.4 -> 3.3.2

Hi,

I’m in the middle of updating Kirby from 3.2.4 to 3.3.2, and I noticed a change in behaviour in the $pages->sortBy() function:

Consider following structure:

parent-page
|-- 1_child-page-e (⭐️)
|-- 2_child-page-d
|-- 3_child-page-c (⭐️)
|-- 4_child-page-b
|-- 5_child-page-a

Each child page has a boolean “status”-field. c & e have status true (:star:). In previous Kirby upon applying page("parent-page")->children()->sortBy("statusfield", "asc") this was the outcome:

  • 1_child-page-e (:star:)
  • 3_child-page-c (:star:)
  • 2_child-page-d
  • 4_child-page-b
  • 5_child-page-a

but in 3.3.2 this seems to get reordered alphabetically first:

  • 3_child-page-c (:star:)
  • 1_child-page-e (:star:)
  • 5_child-page-a
  • 4_child-page-b
  • 2_child-page-d

This is not what I want. I want the manually sorted order to persist when the sortby happens (status first). Any clues how?

Not testet. But something like this should work:

page("parent-page")->children()->sortBy("statusfield", "asc", "num", "asc");

page()->sortBy("order", "asc")->sortBy("statusfield", "asc") seem to do the trick, but this seems so superfluous to me. Is this a regression?

1 Like

Added an issue: https://github.com/getkirby/kirby/issues/2398